I familiar with the fact that I should set the HTTP_RPOXY environment variable to the proxy address.
Generally urllib works fine, the problem is dealing with urllib2.
>>> urllib2.urlopen("http://www.google.com").read()
returns
urllib2.URLError: <urlopen error [Errno 10061] No connection could be made because the target machine actively refused it>
or
urllib2.URLError: <urlopen error [Errno 11004] getaddrinfo failed>
Extra info:
urllib.urlopen(….) works fine! It is just urllib2 that is playing tricks…
I tried @Fenikso answer but I’m getting this error now:
URLError: <urlopen error [Errno 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>
Any ideas?
You can do it even without the HTTP_PROXY environment variable. Try this sample:
In your case it really seems that the proxy server is refusing the connection.
Something more to try:
Edit 2014:
This seems to be a popular question / answer. However today I would use third party
requestsmodule instead.For one request just do:
For multiple requests use
Sessionobject so you do not have to addproxiesparameter in all your requests: