urllib2.ProxyHandler

John J. Lee jjl at pobox.com
Thu Apr 20 15:53:56 EDT 2006


"rx" <do_not_use_this_email at hotmail.com> writes:

> I'm trying to hide my IP with the following code:
>
> import urllib2
> proxy=[urllib2.ProxyHandler({'http':'24.232.167.22:80'})]
> opener=urllib2.build_opener(proxy)

build_opener takes *args, not a list:

import urllib2
handlers = [urllib2.ProxyHandler({'http':'24.232.167.22:80'})]
opener = urllib2.build_opener(*handlers)


or just:

import urllib2
proxy_handler = urllib2.ProxyHandler({'http':'24.232.167.22:80'})
opener = urllib2.build_opener(proxy_handler)


Also, IIRC 2.4 does not allow ports in proxy specification strings
(the values in the dict you pass to ProxyHandler's constructor), and
IIRC 2.5a1 ProxyHandler is broken (it's fixed in the SVN repository).


John




More information about the Python-list mailing list