473,396 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

urllib2.ProxyHandler

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....

Apr 18 '06 #1
1 7979
"rx" <do*******************@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

Apr 20 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: O. Koch | last post by:
Until now, i know that ftplib doesn't support proxies and that i have to use urllib2. But i don't know how to use the urllib2 correct. I found some examples, but i don't understand them. Is...
2
by: Andre Bocchini | last post by:
I'm having some trouble using proxy authentication. I can't figure out how to authenticate with a Squid proxy. I know for a fact the proxy is using Basic instead of Digest for the authentication....
4
by: bmiras | last post by:
I've got a problem using urllib2 to get a web page. I'm going through a proxy using user/password authentification and i'm trying to get a page asking for a HTTP authentification. And I'm using...
0
by: Lee, Dustin | last post by:
I'm using python2.2.2 on redhat linux 7.3 Here's a snippet of what I'm trying to run: # set up proxy import urllib2 proxy_support =...
2
by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line...
1
by: Ray Slakinski | last post by:
Hello, I have defined a function to set an opener for urllib2, this opener defines any proxy and http authentication that is required. If the proxy has authencation itself and requests an...
6
by: Alejandro Dubrovsky | last post by:
I see from googling around that this is a popular topic, but I haven't seen anyone saying "ah, yes, that works", so here it goes. How does one connect through a proxy which requires basic...
1
by: est | last post by:
A simple py script import urllib2 req=urllib2.Request("http://www.google.com") req.set_proxy("127.0.0.1:1","http") print urllib2.urlopen(req).read()
6
by: Jack | last post by:
I'm trying to use a proxy server with urllib2. So I have managed to get it to work by setting the environment variable: export HTTP_PROXY=127.0.0.1:8081 But I wanted to set it from the code....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.