Python请求不适用于https代理
发布于 2021-01-29 15:03:50
我尝试像这样在python中使用https代理:
proxiesDict ={
'http': 'http://' + proxy_line,
'https': 'https://' + proxy_line
}
response = requests.get('https://api.ipify.org/?format=json', proxies=proxiesDict, allow_redirects=False)
proxy_line
是从文件读取的代理,格式为ip:port。我在浏览器中检查了这个https代理,它可以工作。但是在python中,此代码挂起了几秒钟,然后出现异常:
HTTPSConnectionPool(host='api.ipify.org', port=443): Max retries exceeded with url: /?format=json (Caused by ProxyError('Cannot connect to proxy.', NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x0425E450>: Failed to establish a new connection: [WinError 10060]
我尝试使用socks5代理,它适用于安装了PySocks的socks5代理。但是对于https我有这个例外,有人可以帮我吗
关注者
0
被浏览
45
1 个回答