urllib2 disable proxy

Rob Wolfe rw at smsnet.pl
Wed Jan 2 22:36:27 CET 2008


Dimitrios Apostolou <jimis at gmx.net> writes:

> Hello list, 
>
> I've been looking for a way to explicitly disable the use of proxies with 
> urllib2, no matter what the environment dictates. Unfortunately I can't find 
> a way in the documentation, and reading the source leads me to believe that 
> something like the following does the job: 
>
> req.set_proxy(None,None)
>
> Where req is a urllib2.Request instance. So is there an official way of doing 
> this? Perhaps it should be added in the documentation?

I believe that the recommended way is to use `urllib2.ProxyHandler`.
Take a look at:
http://www.voidspace.org.uk/python/articles/urllib2.shtml

HTH,
Rob



More information about the Python-list mailing list