473,398 Members | 2,335 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,398 software developers and data experts.

urllib2 and proxy question

urllib2 (under windows) will auto-detect your proxy settings and use
those.

Normally that's a good thing (I guess), except when it's not !

How do I switch off this behaviour ? I'm behind a censoring proxy and
wanting to test things *locally*. IE is set to not use the proxy when
fetching local adresses, but urllib2 ignores that part of the setting
and uses the proxy for everything.

The only way I can test are changing my IE settings back and forth
every time. Most annoying.

I can see how to *add* a new proxy to urllib2, but not how to force it
to not use a proxy. I may well be missing something obvious though.
Anyone able to help ?
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Jul 18 '05 #1
4 3500
rbt
Fuzzyman wrote:
urllib2 (under windows) will auto-detect your proxy settings and use
those.

Normally that's a good thing (I guess), except when it's not !

How do I switch off this behaviour ? I'm behind a censoring proxy and
wanting to test things *locally*. IE is set to not use the proxy when
fetching local adresses, but urllib2 ignores that part of the setting
and uses the proxy for everything.

The only way I can test are changing my IE settings back and forth
every time. Most annoying.

I can see how to *add* a new proxy to urllib2, but not how to force it
to not use a proxy. I may well be missing something obvious though.
Anyone able to help ?
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml


"Alternatively, the optional proxies argument may be used to explicitly
specify proxies.
It must be a dictionary mapping scheme names to proxy URLs, where an
empty dictionary causes no proxies to be used"

# Don't use any proxies
filehandle = urllib.urlopen(some_url, proxies={})
Jul 18 '05 #2

rbt wrote:
Fuzzyman wrote:
urllib2 (under windows) will auto-detect your proxy settings and use those.

Normally that's a good thing (I guess), except when it's not !

How do I switch off this behaviour ? I'm behind a censoring proxy and wanting to test things *locally*. IE is set to not use the proxy when fetching local adresses, but urllib2 ignores that part of the setting and uses the proxy for everything.

The only way I can test are changing my IE settings back and forth
every time. Most annoying.

I can see how to *add* a new proxy to urllib2, but not how to force it to not use a proxy. I may well be missing something obvious though.
Anyone able to help ?
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

"Alternatively, the optional proxies argument may be used to

explicitly specify proxies.
It must be a dictionary mapping scheme names to proxy URLs, where an
empty dictionary causes no proxies to be used"

# Don't use any proxies
filehandle = urllib.urlopen(some_url, proxies={})


Wikkid... I'll try that. Nice one, thanks for your help.
It *still* means I have to have a different version for testing locally
- but it's better than the alternative.
Regards,
Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Jul 18 '05 #3

rbt wrote:
Fuzzyman wrote:
urllib2 (under windows) will auto-detect your proxy settings and use those.

Normally that's a good thing (I guess), except when it's not !

How do I switch off this behaviour ? I'm behind a censoring proxy and wanting to test things *locally*. IE is set to not use the proxy when fetching local adresses, but urllib2 ignores that part of the setting and uses the proxy for everything.

The only way I can test are changing my IE settings back and forth
every time. Most annoying.

I can see how to *add* a new proxy to urllib2, but not how to force it to not use a proxy. I may well be missing something obvious though.
Anyone able to help ?
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

"Alternatively, the optional proxies argument may be used to

explicitly specify proxies.
It must be a dictionary mapping scheme names to proxy URLs, where an
empty dictionary causes no proxies to be used"

# Don't use any proxies
filehandle = urllib.urlopen(some_url, proxies={})


Rats.. this answer is for urllib - *NOT* urllib2 !
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Jul 18 '05 #4

rbt wrote:
Fuzzyman wrote:
urllib2 (under windows) will auto-detect your proxy settings and use
those.

Normally that's a good thing (I guess), except when it's not !

How do I switch off this behaviour ? I'm behind a censoring proxy and wanting to test things *locally*. IE is set to not use the proxy when fetching local adresses, but urllib2 ignores that part of the setting and uses the proxy for everything.

The only way I can test are changing my IE settings back and forth
every time. Most annoying.

I can see how to *add* a new proxy to urllib2, but not how to force it to not use a proxy. I may well be missing something obvious though.
Anyone able to help ?
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

"Alternatively, the optional proxies argument may be used to

explicitly specify proxies.
It must be a dictionary mapping scheme names to proxy URLs, where an
empty dictionary causes no proxies to be used"

# Don't use any proxies
filehandle = urllib.urlopen(some_url, proxies={})


The correct equivalent for urllib2 (in answer to my question !) is :
proxy_support = urllib2.ProxyHandler({})
opener = urllib2.build_opener(proxy_support)
urllib2.install_opener(opener)


which is slightly more complicated but does exactly the same job !
Regards,

Fuzzy
http://www.voidspace.org.uk/python/index.shtml

Jul 18 '05 #5

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...
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 =...
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...
3
by: itay_k | last post by:
Hi, I am running the following simple code (just open connection to some https page with proxy): proxy= '666.179.227.666:80' proxy=urllib2.ProxyHandler({"https":'https://'+proxy}) opener =...
1
by: Alessandro Fachin | last post by:
I write this simply code that should give me the access to private page with htaccess using a proxy, i don't known because it's wrong... import urllib,urllib2 #input url...
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....
1
by: Larry Hale | last post by:
Since it seems I have a "unique" problem, I wonder if anyone could point me in the general/right direction for tracking down the issue and resolving it myself. See my prior post @...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.