在requests中使用proxy代理訪問
使用前先更新requests版本為支持socks的版本。
先pip安裝對應庫:
>> pip install -U requests[socks]
腳本添加和使用代理:
import requests
....
proxy = {
'http': '
socks5://10.20.3.10:7071',
'https': '
socks5://10.20.3.10:7071'
}
....
# 使用代理發送請求
....
ret = requests.post(url, json=params, proxies=proxy).content
....