我尝试在 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)
Run Code Online (Sandbox Code Playgroud)
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]
Run Code Online (Sandbox Code Playgroud)
我尝试使用socks5代理,它适用于安装了PySocks的socks5代理。但是对于 https 我遇到了这个异常,有人可以帮助我吗