urllib proxy question?

John J. Lee jjl at pobox.com
Sat May 8 12:37:31 EDT 2004


"Alex Santos" <alex.santos at gmx.net> writes:

> i wrote a python prog that reads a url via urlib to find out the public ip
> of the computer, my problem is that, if someone sets a proxy in teh internet
> explorer, the urllib works also over a proxy and i dont get the right public
> ip of my computer?
> 
> has sombody an idea, how to disable this behavior of the urllib?

>From a quick look at the source (urllib.py):

import urllib
opener = urllib.FancyURLopener(proxies={})
r = opener.open("http://www.python.org/")
print r.read()


urllib2 will also allow you to turn off proxy support (though the docs
for proxies are a bit lacking, IIRC).

Of course, your ISP may proxy your requests even if your computer
thinks it has a 'direct' internet connection.

Presumably there's a better way, but I don't know what it is.

Why do you need to know, anyway?


John



More information about the Python-list mailing list