网络有代理时,使用()等请求,会提示超时。在请求中加入代理设置,就可以正常使用。
代理设置不同python版本有不同的写法
1. python3.8以下版本:
proxies{' 要请求网站的协议类型 ' , ' 代理服务器ip : 端口 '}
2. python3.8以上版本:proxies{' 要请求网站的协议类型 ' , ' "代理服务器类型(http/https/socks5)://代理服务器ip : 端口 '}
python3.8以下版本的用法
proxy = {'https':'192.168.1.1:8080'}
urls = '/'
(url=urls,params=param,proxies=proxy)
python3.8以上版本的用法
proxy = {'https':'http://192.168.1.1:8080'}
urls = '/'
(url=urls,params=param,proxies=proxy)