Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > urllib2.ProxyHandler

Reply
Thread Tools

urllib2.ProxyHandler

 
 
rx
Guest
Posts: n/a
 
      04-18-2006
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....



 
Reply With Quote
 
 
 
 
John J. Lee
Guest
Posts: n/a
 
      04-20-2006
"rx" <> 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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57