最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Python requests設(shè)置代理的方法步驟

 更新時(shí)間:2020年02月23日 10:43:35   作者:丫丫博客  
這篇文章主要介紹了Python requests設(shè)置代理的方法步驟,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧

指導(dǎo)文檔:
http://docs.python-requests.org/en/master/user/advanced/ 的Proxies
http://docs.python-requests.org/en/latest/user/advanced/ 的SSL Cert Verification

requests設(shè)置代理

import requests
proxies = {'http': 'http://localhost:8888', 'https': 'http://localhost:8888'}
url = 'http://www.baidu.com'
requests.post(url, proxies=proxies, verify=False) #verify是否驗(yàn)證服務(wù)器的SSL證書

執(zhí)行結(jié)果:

基于 selenium的代理設(shè)置:

from selenium import webdriver

proxy='124.243.226.18:8888'

option=webdriver.ChromeOptions()

option.add_argument('--proxy-server=http://'+proxy)

driver = webdriver.Chrome(options=option)

driver.get('http://httpbin.org/get')

python3.8 request proxy(代理)失效解決方案

在使用python3.8版本的時(shí)候,我們使用request庫的時(shí)候,可能會遇到

urllib3.exceptions.ProxySchemeUnknown: Not supported proxy scheme None

下面這樣的錯(cuò)誤,這是游戲底層修改了url解析模式,導(dǎo)致proxy代理解析失敗導(dǎo)致的。

解決方案是:

如果不使用代理,那么就可以改成

proxies = {

"http": "",

"https": "",

}

request.get(url,proxies=proxies)

如果使用代理的話,就可以修改成:

proxies = {

"http":" http://127.0.0.1:1080",

"https":"https://127.0.0.1:1080",

}

需要注意的是,一定要寫成http://+ip+port這種形式,不能去掉前面的http://,否則就會產(chǎn)生錯(cuò)誤。

到此這篇關(guān)于Python requests設(shè)置代理的方法步驟的文章就介紹到這了,更多相關(guān)Python requests設(shè)置代理內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論

十堰市| 乌鲁木齐县| 中牟县| 武安市| 广宗县| 金沙县| 兴安县| 宁陵县| 土默特左旗| 洛宁县| 夏津县| 乐清市| 安平县| 辽中县| 阆中市| 麻城市| 漠河县| 泾阳县| 新民市| 禹城市| 江川县| 吴桥县| 双鸭山市| 高清| 克东县| 塔河县| 广德县| 招远市| 肥东县| 清流县| 永年县| 阿拉尔市| 宁明县| 红河县| 常宁市| 毕节市| 深圳市| 泰兴市| 凤山市| 赤水市| 中超|