Python httplib2 模块,debuglevel() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用httplib2.debuglevel()

项目:Snakepit    作者:K4lium    | 项目源码 | 文件源码
def _fortiURL(self, urlInput): 
        httplib2.debuglevel = 4          

        conn = urllib2.urlopen("http://www.fortiguard.com/ip_rep.php?data=" + urlInput + "&lookup=Lookup", timeout=60)
        content2String = conn.read()        

        rpd = re.compile('h3\sstyle\=\"float:\sleft\"\>Category:\s(.+)\<\/h3', re.IGNORECASE)
        rpdFind = re.findall(rpd, content2String)
        rpdSorted = rpdFind

        m = ''
        for m in rpdSorted:
            fortiGuard = urlInput + " Categorization: " + m  

            if MALICIOUS in m:
                self.hitcount += 1
        if m == '':
            fortiGuard = urlInput + " Categorization: Uncategorized"   

        return fortiGuard
项目:Remote_raspberrypi_GPIO_Control    作者:Rahul14singh    | 项目源码 | 文件源码
def proxyConnect(self,UID, token):
        my_ip = urlopen('http://ip.42.pl/raw').read()
        httplib2.debuglevel     = 0
        http                    = httplib2.Http()
        content_type_header     = "application/json"
        proxyConnectURL = apiMethod + apiServer + apiVersion + "/api/device/connect"

        proxyHeaders = {
            'Content-Type': content_type_header,
            'apikey': apiKey,
            'token': token
            }

        proxyBody = {
            'deviceaddress': UID,
            'hostip': my_ip,
            'wait': "true"
            }

        response, content = http.request(
            proxyConnectURL,
            'POST',
            headers=proxyHeaders,
            body=dumps(proxyBody,cls=PythonObjectEncoder)
            )
        print ("Response = ", response)
        print ("Content = ", content)
        data = json.loads(content.decode('utf-8'))["connection"]["proxy"]
        print(data)
        URI = data.split(":")[0] + ":" + data.split(":")[1]
        URI = URI.split("://")[1]
        portNum = data.split(":")[2]
        print(URI)
        print(portNum)
        val = self.trySSHConnect(URI,int(portNum))
        if val==0:
            print("Yeah Check that it worked")
            return 1
        else:
            return 0
项目:touch-pay-client    作者:HackPucBemobi    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
#            httplib2.debuglevel=4 
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according to supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:true_review_web2py    作者:lucadealfaro    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:spc    作者:whbrewer    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:Problematica-public    作者:TechMaz    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:rekall-agent-server    作者:rekall-innovations    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
#            httplib2.debuglevel=4 
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according to supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:slugiot-client    作者:slugiot    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:StuffShare    作者:StuffShare    | 项目源码 | 文件源码
def __init__(self, timeout, proxy=None, cacert=None, sessions=False):
            ##httplib2.debuglevel=4
            kwargs = {}
            if proxy:
                import socks
                kwargs['proxy_info'] = httplib2.ProxyInfo(proxy_type=socks.PROXY_TYPE_HTTP, **proxy)
                log.info("using proxy %s" % proxy)

            # set optional parameters according supported httplib2 version
            if httplib2.__version__ >= '0.3.0':
                kwargs['timeout'] = timeout
            if httplib2.__version__ >= '0.7.0':
                kwargs['disable_ssl_certificate_validation'] = cacert is None
                kwargs['ca_certs'] = cacert
            httplib2.Http.__init__(self, **kwargs)
项目:Snakepit    作者:K4lium    | 项目源码 | 文件源码
def _urlQuery(self, urlInput):
        httplib2.debuglevel = 4          

        url = "http://urlquery.net/%s"
        action_search = url % "search.php?q=%s" % urlInput

        conn = urllib2.urlopen(action_search, timeout=60)
        content2String = conn.read()      

        rpd = re.compile('.*&nbsp;&nbsp;0\sresults\sreturned*', re.IGNORECASE)
        rpdFind = re.findall(rpd, content2String)

        if not rpdFind:
            # Reports found
            log.debug('urlquery Reports found')
            self.hitcount += 1
            urlqueryResults = []

            rpd = re.compile("\shref='(.*?)'\>", re.IGNORECASE)
            rpdFindReport = re.findall(rpd, content2String)

            rpd = re.compile("\<td\>\<a\stitle='(.*?)'\shref='report.php", re.IGNORECASE)
            rpdFindReportUrl = re.findall(rpd, content2String)               

            rpd = re.compile("\<td\salign='center'\>\<b\>(.*?)\<\/b\>\<\/td\>", re.IGNORECASE)
            rpdFindAlertsIDS = re.findall(rpd, content2String)    

            rpd = re.compile("\<td\>\<nobr\>\<center\>(.*?)\<\/center\>\<\/nobr\>\<\/td\>", re.IGNORECASE)
            rpdFindDatum = re.findall(rpd, content2String)    

            rpd = re.compile("align='left'\stitle='(.*?)'\swidth='\d{2}'\sheight='\d{2}'\s/>", re.IGNORECASE)
            rpdFindLand = re.findall(rpd, content2String)   

            i = 0
            datum = ''
            for datum in rpdFindDatum:   
                result = {} 
                result["datum"] = datum    
                result["alerts_ids"] = rpdFindAlertsIDS[i]
                result["country"] = rpdFindLand[i]
                result["reportUrl"] = convertDirtyDict2ASCII(rpdFindReportUrl[i])
                result["report"] = url % rpdFindReport[i]   
                urlqueryResults.append(result)                   
                i += 1             

            urlquery = {'url':urlInput, 'urlResult':urlqueryResults}
        else:   
            log.debug('urlquery Reports NOT found')  
            urlquery = {'url': urlInput, 'urlResult' : 'NOT listed'}     

        return urlquery
项目:Snakepit    作者:K4lium    | 项目源码 | 文件源码
def _ipVoid(self, ipInput):
        httplib2.debuglevel = 4     

        conn = urllib2.urlopen("http://ipvoid.com/scan/" + ipInput, timeout=60)
        content2String = conn.read()        

        rpNotFound = re.compile('<h1>Report\snot\sfound<\/h1>', re.IGNORECASE)
        rpdFindNotFound = re.findall(rpNotFound, content2String)

        # Report not found -> exit
        if rpdFindNotFound:
            log.info("ipvoid.com: Report not found")
            return {"ip" : ipInput, "ipResult" : {"BlacklistStatus":"Report not found"}} 

        rpd = re.compile('title="Detected"\s\/>\s&nbsp;\s<a.rel=\"nofollow\"\shref="(.{6,200})\"\stitle', re.IGNORECASE)
        rpdFind = re.findall(rpd, content2String)
        rpdSortBlacklist = rpdFind

        rpd = re.compile('label-.*\">(.+)\<\/span\>\<\/td\>\<\/tr\>', re.IGNORECASE)
        rpdFind = re.findall(rpd, content2String)
        rpdSortBlacklistStatus = rpdFind        

        rpd = re.compile('<tr><td>ISP<\/td><td>(.+)<\/td\>\<\/tr\>', re.IGNORECASE)
        rpdFind = re.findall(rpd, content2String)
        rpdSortISP = rpdFind

        rpd = re.compile('Country\sCode</td><td><img.+alt="Flag"\s\/>.(.+)<\/td\>\<\/tr\>', re.IGNORECASE)
        rpdFind = re.findall(rpd, content2String)
        rpdSortCountry = rpdFind

        ipResult = {}

        if "BLACKLISTED" in rpdSortBlacklistStatus[0]:
            ipResult["BlacklistStatus"] = rpdSortBlacklistStatus[0]
            self.hitcount += 1

            blacklist = []
            for j in rpdSortBlacklist:
                blacklist.append({"Blacklist" : 'IP is listed in blacklist at: ' + j})
                self.hitcount += 1

            if blacklist:
                ipResult["Blacklists"] = blacklist            
        else:
            ipResult["BlacklistStatus"] = rpdSortBlacklistStatus[0]   

        if rpdSortISP:
            ipResult["ISP"] = rpdSortISP[0]
        else:
            ipResult["ISP"] = 'No ISP listed'

        if rpdSortCountry:
            ipResult["CountryCode"] = rpdSortCountry[0].strip()
        else:
            ipResult["CountryCode"] = "No Country listed"      

        return {"ip" : ipInput, "ipResult" : ipResult}