该
proxies“字典语法
{"protocol":"ip:port", ...}。使用它,你可以使用http,https和ftp协议为请求指定不同(或相同)的代理:http_proxy = "http://10.10.1.10:3128"https_proxy = "https://10.10.1.11:1080"ftp_proxy = "ftp://10.10.1.10:3128"proxyDict = { "http" : http_proxy, "https" : https_proxy, "ftp" : ftp_proxy }r = requests.get(url, headers=headers, proxies=proxyDict)从requests文档推导:
参数:
method–新Request对象的方法。
url–新的Request对象的URL。
…
proxies–(可选)字典映射 协议到代理URL。
…
在Linux上,你也可以通过这样做HTTP_PROXY,HTTPS_PROXY以及FTP_PROXY环境变量:
export HTTP_PROXY=10.10.1.10:3128export HTTPS_PROXY=10.10.1.11:1080export FTP_PROXY=10.10.1.10:3128
在Windows上:
set http_proxy=10.10.1.10:3128set https_proxy=10.10.1.11:1080set ftp_proxy=10.10.1.10:3128



