urllib2.ProxyHandler

R

rx

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)
f=opener.open('http://www.whatismyipaddress.com')
print f.read()

But that didn't work - my real IP showed up.

Then I made the following replacement:

proxy=[urllib2.ProxyHandler({'http':'24.232.167.22:80'})] ->
proxy=[urllib2.ProxyHandler({'http':'foo'})]

And got the exact same result.

What am I doing wrong ?
Do I need a name instead of 24.232.167.22 ? (but this IP and some others I
tried didn't have a name)

Thanks in advance....
 
J

John J. Lee

rx said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top