代理

#requests.get(url,proxies=proxies)#设置代理

import requests

#1.使用代理
proxies = {
"http":"http://10.10.1.10:3128",
"https":"http://10.10.1.10:1080"
}
requests.get("http://example.org",proxies=proxies)

#2.可以设置环境变量
$ export HTTP_PROXY="http://10.10.1.10:3128"
$ export HTTPS_PROXY="http://10.10.1.10:1080"
$ python
requests.get("http://example.org")

#3.若代理需要使用HTTP Bsaic Auth,可以用http://user:password@host/语法
proxies = {"http":"http://user:pass@10.10.1.10:3128"}

#4.要为某个特定的链接方式或主机设置代理,使用scheme://hostname作为key,针对指定的主机和连接方式进行匹配
proxies = {"http://10.20.1.128":"http://10.10.1.10:5323"}

#5.SOCKS
proxies = {"http":"socks5://user:pass@host:port",
"https":"socks5://user:pass@host:port"}
原文地址:https://www.cnblogs.com/smile2018tao/p/10171692.html