How to disable urllib2 HTTP proxy on Windows?

C

Carl Waldbieser

**** Post for FREE via your newsreader at post.usenet.com ****

When using urllib2.urlopen() on my Windows 2000 machine at work, I was
puzzled that I kept getting back authentication errors from our Internet
proxy server (I was trying to contact an internal machine). Upon digging
into the code a little, I found that urllib2 was pulling the proxy
information out of the Windows registry (Internet Explorer uses these
settings). However, the browser also had settings to disable use of the
proxy for local addresses, and any specific addresses or wildcards I gave
it. urllib2 seemed to be ignoring those.

In the Python library reference, I read that setting the HTTP_PROXY
environment variable could set a proxy, as could installing a new opener.
However, I tried to turn off proxy support by setting HTTP_PROXY="", and I
got an error for my trouble (don't recall exact error right now-- am at
home on my GNU/Linux system). Is it possible to turn off proxy support in
Python while leaving the browser settings untouched? I was really quite
surprised when I found out that Python was using the browser's proxy
settings on my behalf.

Thanks,
Carl Waldbieser

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
http://www.usenet.com
Unlimited Download - 19 Seperate Servers - 90,000 groups - Uncensored
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 
A

Andrew MacIntyre

In the Python library reference, I read that setting the HTTP_PROXY
environment variable could set a proxy, as could installing a new opener.
However, I tried to turn off proxy support by setting HTTP_PROXY="", and I
got an error for my trouble (don't recall exact error right now-- am at
home on my GNU/Linux system). Is it possible to turn off proxy support in
Python while leaving the browser settings untouched? I was really quite
surprised when I found out that Python was using the browser's proxy
settings on my behalf.

As I recall, you can do this by passing an empty container (can't remember
whether its a list or dict) to the URL opener factory.
 

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

No members online now.

Forum statistics

Threads
473,982
Messages
2,570,189
Members
46,735
Latest member
HikmatRamazanov

Latest Threads

Top