當前位置: 首頁>>代碼示例>>Python>>正文


Python urllib3.disable_warnings方法代碼示例

本文整理匯總了Python中requests.packages.urllib3.disable_warnings方法的典型用法代碼示例。如果您正苦於以下問題:Python urllib3.disable_warnings方法的具體用法?Python urllib3.disable_warnings怎麽用?Python urllib3.disable_warnings使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在requests.packages.urllib3的用法示例。


在下文中一共展示了urllib3.disable_warnings方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: download_tarball

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def download_tarball(tarball_url, verify=False, proxy_server=None):
    '''
    Downloads a tarball to /tmp and returns the path
    '''
    try:
        if not verify:
            urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
        kwargs = {}
        if proxy_server:
            kwargs['proxies'] = {
                'http': proxy_server,
                'https': proxy_server,
                'ftp': proxy_server
            }
        tarball_filename = tempfile.mkstemp(prefix='armada')[1]
        response = requests.get(tarball_url, verify=verify, **kwargs)

        with open(tarball_filename, 'wb') as f:
            f.write(response.content)

        return tarball_filename
    except Exception:
        raise source_exceptions.TarballDownloadException(tarball_url) 
開發者ID:airshipit,項目名稱:armada,代碼行數:25,代碼來源:source.py

示例2: download_tarball

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def download_tarball(tarball_url, verify=False):
    '''
    Downloads a tarball to /tmp and returns the path
    '''
    try:
        if not verify:
            urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

        tarball_filename = tempfile.mkstemp(prefix='armada')[1]
        response = requests.get(tarball_url, verify=verify)

        with open(tarball_filename, 'wb') as f:
            f.write(response.content)

        return tarball_filename
    except Exception:
        raise source_exceptions.TarballDownloadException(tarball_url) 
開發者ID:att-comdev,項目名稱:armada,代碼行數:19,代碼來源:source.py

示例3: get_html

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def get_html(url,submit_cookies):

    # 設置請求頭,模擬人工
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
        'Referer' : 'http://ui.ptlogin2.qq.com/cgi-bin/login?appid=549000912&s_url=http://qun.qq.com/member.html'
    }
    # 屏蔽https證書警告
    urllib3.disable_warnings()

    # 網頁訪問,get方式
    html = get(url, cookies = submit_cookies, headers=header, verify=False)

    return html


# post訪問網頁 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:19,代碼來源:url_request.py

示例4: get_profile_picture

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def get_profile_picture(self, qq_number, size=100):
        # 獲取指定qq的頭像,size的值可為40、100、140,默認為100
        # 屏蔽https證書警告
        urllib3.disable_warnings()

        # 設置請求頭,模擬人工
        header = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Referer':'http://find.qq.com/'
        }

        # 網頁訪問,get方式
        html = get('http://q1.qlogo.cn/g?b=qq&nk=' + str(qq_number) + '&s=' + str(size), headers=header, verify=False)
        return html.content 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:18,代碼來源:qq_bot.py

示例5: get_quit_of_group

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def get_quit_of_group(self):
        # 獲取最近30天內退出的群
        # 需要提交的數據
        # bkn由參數skey通過另一個加密函數得到
        bkn = hash33_bkn(self.cookies_merge_dict_in_qun_qq_com['skey'])
        submit_data = {'bkn': str(bkn)}

        # 設置請求頭,模擬人工
        header = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
            'Content-Type': 'text/plain',
            'origin': 'https://huifu.qq.com',
            'referer' : 'https://huifu.qq.com/recovery/index.html?frag=0'
        }

        # 屏蔽https證書警告
        urllib3.disable_warnings()
        # 網頁訪問,post方式
        html = post('https://huifu.qq.com/cgi-bin/gr_grouplist', data=submit_data, cookies=self.cookies_merge_dict_in_qun_qq_com, headers=header, verify=False)

        # 將返回數據解析為python對象
        result = loads(html.text)

        return result 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:27,代碼來源:qq_bot.py

示例6: get_pay_for_another

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def get_pay_for_another(self):
        # 獲取幫別人的代付
        # 需要提交的數據
        skey = str(self.cookies_merge_dict_in_qun_qq_com['skey'])
        url = 'https://pay.qq.com/cgi-bin/personal/account_msg.cgi?p=0.6796416908412624&cmd=1&sck=' + get_sck(skey) + '&type=100&showitem=2&per=100&pageno=1&r=0.3177912609760205'

        # 設置請求頭,模擬人工
        header = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
            'Accept-Encoding': 'gzip, deflate',
            'Referer': 'https://pay.qq.com/infocenter/infocenter.shtml?asktype=100',
            'Connection': 'keep-alive'
        }

        # 屏蔽https證書警告
        urllib3.disable_warnings()
        # 網頁訪問,get方式
        html = get(url, cookies=self.cookies_merge_dict_in_qun_qq_com, headers=header, verify=False)

        # 將返回數據解析為python對象
        result = loads(html.text)
        # print(result)

        return result['resultinfo']['list'] 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:27,代碼來源:qq_bot.py

示例7: __init__

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def __init__(self, base_url, login, password, verify_tls=True, timeout=None, **options):
        self.options = options
        self.key_patterns = {prepare_regex(metric['key']): metric
                             for metric in options.get('metrics', [])}

        self.zapi = pyzabbix.ZabbixAPI(base_url, timeout=timeout)
        if not verify_tls:
            import requests.packages.urllib3 as urllib3
            urllib3.disable_warnings()
            self.zapi.session.verify = verify_tls

        def measure_api_request(r, *args, **kwargs):
            api_requests_total.inc()
            api_bytes_total.inc(len(r.content))
            api_seconds_total.inc(r.elapsed.total_seconds())
        self.zapi.session.hooks = {'response': measure_api_request}

        self.zapi.login(login, password)

        self.host_mapping = {row['hostid']: row['name']
                             for row in self.zapi.host.get(output=['hostid', 'name'])} 
開發者ID:MyBook,項目名稱:zabbix-exporter,代碼行數:23,代碼來源:core.py

示例8: __init__

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def __init__(self, version, address='https://index.docker.io', **kwargs):
        urllib3.disable_warnings()
        self._instances[id(self)] = self
        self.scheme       = utils.parse_http_scheme(address)
        self.location     = utils.parse_hostname(address)
        self._api_version = version
        self._tls         = {}

        if kwargs.get('ssl_cert_path'):
            self.tls = kwargs['ssl_cert_path']

        # prepare session
        self.session = requests.Session()

        # set up certs.
        self.session.verify = self.tls.get('ca_path', kwargs.get('verify', True))
        self.session.cert = (self.tls['ssl_cert_path'], self.tls['ssl_key_path']) if self.tls else None
        self.auth = kwargs.get('authentication', kwargs.get('auth', None))
        if self.auth:
            self.session.auth = (self.auth.user, self.auth.passwd) 
開發者ID:TUNE-Archive,項目名稱:freight_forwarder,代碼行數:22,代碼來源:registry_base.py

示例9: __init__

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def __init__(self):
        self.state = Session.STATE_INIT
        self.credentials = None
        self.session = None
        self.auth = None
        self.retrying = False	# Avoid infinite loop when successful auth / unsuccessful query

        # yuck suppress InsecurePlatformWarning under Python < 2.7.9 which lacks SNI support
        if sys.version_info < (2,7,9):
            from requests.packages import urllib3
            urllib3.disable_warnings()

        if getattr(sys, 'frozen', False):
            os.environ['REQUESTS_CA_BUNDLE'] = join(config.respath, 'cacert.pem') 
開發者ID:EDCD,項目名稱:EDMarketConnector,代碼行數:16,代碼來源:companion.py

示例10: init_session

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def init_session(cls):
        if "Authorization" not in cls._session.headers and config.api_token:
            cls._session.headers.update({"Authorization": "Bearer {}".format(config.api_token)})
        if cls._session.cert is None and config.cert:
            cls._session.cert = config.cert
        cls._session.verify = config.verify_ssl
        if not config.verify_ssl:
            import requests.packages.urllib3 as urllib3
            urllib3.disable_warnings() 
開發者ID:fiaas,項目名稱:k8s,代碼行數:11,代碼來源:client.py

示例11: disable_ssl_cert_check

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def disable_ssl_cert_check(self):
        urllib3.disable_warnings(InsecureRequestWarning)
        self.s.verify = False 
開發者ID:sparkcognition,項目名稱:darwin-sdk,代碼行數:5,代碼來源:sdk.py

示例12: post_html

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def post_html(url,submit_cookies,submit_data):

    # 設置請求頭,模擬人工
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
        'Referer' : 'https://qun.qq.com/member.html'
    }
    # 屏蔽https證書警告
    urllib3.disable_warnings()

    # 網頁訪問,post方式
    html = post(url, data=submit_data, cookies = submit_cookies, headers=header, verify=False)

    return html 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:16,代碼來源:url_request.py

示例13: get_info_in_qq_friend

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def get_info_in_qq_friend(self,qq_number):

        # 獲取某個qq好友的詳細信息

        # 需要提交的數據
        # bkn由參數skey通過另一個加密函數得到
        bkn = hash33_bkn(self.cookies_merge_dict_in_qun_qq_com['skey'])
        submit_data = {'keyword':str(qq_number), 'ldw': str(bkn), 'num':'20', 'page':'0', 'sessionid':'0', 'agerg':'0', 'sex':'0', 'firston':'0', 'video':'0', 'country':'1', 'province':'65535', 'city':'0', 'district':'0', 'hcountry':'1', 'hprovince':'0', 'hcity':'0', 'hdistrict':'0', 'online':'0'}

        # 需要提交的cookies
        # cookies = {'uin':self.cookies_merge_dict_in_qun_qq_com['uin'], 'skey':self.cookies_merge_dict_in_qun_qq_com['skey'], 'ptisp':self.cookies_merge_dict_in_qun_qq_com['ptisp'], 'RK':self.cookies_merge_dict_in_qun_qq_com['RK'], 'ptcz':self.cookies_merge_dict_in_qun_qq_com['ptcz']}

        # 設置請求頭,模擬人工
        header = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'Origin': 'http://find.qq.com',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
            'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
            'Referer':'http://find.qq.com/',
        }

        # 屏蔽https證書警告
        urllib3.disable_warnings()
        # 網頁訪問,post方式
        html = post('http://cgi.find.qq.com/qqfind/buddy/search_v3', data=submit_data, cookies=self.cookies_merge_dict_in_qun_qq_com, headers=header, verify=False)

        # 將好友信息解析為python對象
        friend_info = loads(html.text)
        # print(friend_info)
        return friend_info['result']['buddy']['info_list'][0] 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:32,代碼來源:qq_bot.py

示例14: is_vip_svip

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def is_vip_svip(self):
        # 判斷此次登錄的qq是否為vip或者svip
        # 需要提交的數據
        # bkn由參數skey通過另一個加密函數得到
        bkn = hash33_bkn(self.cookies_merge_dict_in_qun_qq_com['skey'])
        qq_number = str(self.qq_number)
        skey = str(self.cookies_merge_dict_in_qun_qq_com['skey'])
        url = 'https://proxy.vip.qq.com/cgi-bin/srfentry.fcgi?bkn=' + str(bkn) + '&ts=&g_tk=' + str(bkn) + '&data={"11053":{"iAppId":1,"iKeyType":1,"sClientIp":"","sSessionKey":"' + skey + '","sUin":"' + qq_number + '"}}'

        # 設置請求頭,模擬人工
        header = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
            'Accept-Encoding': 'gzip, deflate',
            'Referer': 'https://huifu.qq.com/recovery/index.html?frag=1',
            'Origin': 'https://huifu.qq.com',
            'Connection': 'close'
        }

        # 屏蔽https證書警告
        urllib3.disable_warnings()
        # 網頁訪問,post方式
        html = get(url, cookies=self.cookies_merge_dict_in_qun_qq_com, headers=header, verify=False)

        # 將返回數據解析為python對象
        result = loads(html.text)
        isSvip = result['11053']['data']['isSvip']
        isVip = result['11053']['data']['isVip']
        return {'isSvip':isSvip, 'isVip':isVip} 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:31,代碼來源:qq_bot.py

示例15: get_qb

# 需要導入模塊: from requests.packages import urllib3 [as 別名]
# 或者: from requests.packages.urllib3 import disable_warnings [as 別名]
def get_qb(self):
        # 獲取該賬戶的qb值
        # 需要提交的數據
        qq_number = str(self.qq_number)
        skey = str(self.cookies_merge_dict_in_qun_qq_com['skey'])
        url = 'https://api.unipay.qq.com/v1/r/1450000186/wechat_query?cmd=4&pf=vip_m-pay_html5-html5&pfkey=pfkey&from_h5=1&from_https=1&openid=' + qq_number + '&openkey=' + skey + '&session_id=uin&session_type=skey'

        # 設置請求頭,模擬人工
        header = {
            'Accept': 'application/json, text/javascript, */*; q=0.01',
            'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36',
            'Accept-Encoding': 'gzip, deflate',
            'Referer': 'https://my.pay.qq.com/account/index.shtml',
            'Origin': 'https://my.pay.qq.com',
            'Connection': 'close'
        }

        # 屏蔽https證書警告
        urllib3.disable_warnings()
        # 網頁訪問,get方式
        html = get(url, cookies=self.cookies_merge_dict_in_qun_qq_com, headers=header, verify=False)

        # 將返回數據解析為python對象
        result = loads(html.text)

        qb_value = float(result['qb_balance']) / 10
        return qb_value 
開發者ID:shengqiangzhang,項目名稱:examples-of-web-crawlers,代碼行數:29,代碼來源:qq_bot.py


注:本文中的requests.packages.urllib3.disable_warnings方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。