I know how to use requests very well, yet for some reason I am not succeeding in getting the proxies working. I am making the following request:
r = requests.get('http://whatismyip.com', proxies={'http': 'http://148.236.5.92:8080'})
I get the following:
requests.exceptions.ConnectionError: [Errno 10060] A connection attempt failed b
ecause the connected party did not properly respond after a period of time, or e
stablished connection failed because connected host has failed to respond
Yet, I know the proxy works, because using node:
request.get({uri: 'http://www.whatismyip.com', proxy: 'http://148.236.5.92:8080'},
function (err, response, body) {var $ = cheerio.load(body); console.log($('#greenip').text());});
I get the following (correct) response:
148.236.5.92
Furthermore, when I try the requests request at all differently (say, without writing http:// in front of the proxy), it just allows the request to go through normally without going through a proxy or returning an error.
What am I doing wrong in Python?
It's a known issue: https://github.com/kennethreitz/requests/issues/1074
I'm not sure exactly why it's taking so long to fix though. To answer your question though, you're doing nothing wrong.
As sigmavirus24 says, this is a known issue, which has been fixed, but hasn't yet been packaged up into a new version and pushed to PyPI.
So, if you need this in a hurry, you can upgrade from the git repo's master.
If you're using pip, this is simple. Instead of this:
pip install -U requests
Do this:
pip install -U git+https://github.com/kennethreitz/requests
If you're not using pip, you'll probably have to explicitly git clone the repo, then easy_install . or python setup.py or whatever from your local copy.