我想在python请求中使用代理,但是当我像这样运行代码时
req = requests.get("https://httpbin.org/ip", proxies={'https': 'user:pass@host:port',
'http': 'user:pass@host:port'})
print(req.content)
我收到此错误
HTTPSConnectionPool(host='httpbin.org', port=443): Max retries exceeded with url: /ip (Caused by ProxyError('Cannot connect to proxy.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None
但是如果我使用“ http://httpbin.org/ip”而不是“ https://httpbin.org/ip”
它真的很好
以及其他类似我运行此代码的内容
proxies = { 'http' : 'user:pass@host:port' }
req =requests.get("https://lumtest.com/myip.json",proxies =proxies )
print(req.content)
我得到了我的IP地址,这意味着代理不起作用。但是如果我用这个 这是相同的网址,只是在https中没有s,我通过HTTP运行它
proxies = { 'http' : 'user:pass@host:port' }
req =requests.get("http://lumtest.com/myip.json",proxies =proxies )
print(req.content)
我获得了代理服务器的IP,这意味着它可以正常工作
在HTTP或HTTPS中使用s代理服务器并没有改变我的麻烦,但是在某些网站上 我得到一个不同的回应
b''
即使没有在HTTPS或HTTP上运行它,也没有得到我想要的响应就可以正常工作而无需代理
但是如果我运行它,它只能在带有代理的http上运行,并且不会给出有效的响应
我希望有人可以帮助我,因为我一直试图永远解决这个问题