How to ignore windows proxy settings using python urllib?

I want Python to ignore Windows proxy settings when used urllib. The only way I was able to do this was to disable all proxy settings in Internet Explorer. Is there a software way?

os.environ['no_proxy'] not a good option, as I would like to avoid a proxy for all addresses.

+5
source share
4 answers

Go to urlopen

proxies={}

or try:

urllib.getproxies = lambda x = None: {}

immediately after importing urllib (information found here ).

+3
source

urlib2 : urllib2.ProxyHandler([proxies])... , .

, :

import urllib2
proxy = urllib2.ProxyHandler({}) # Pass empty dictionary to bypass proxy
opener = urllib2.build_opener(proxy)
urllib2.install_opener(opener)
socket = urllib2.urlopen('http://www.google.com')
content = socket.read() 
+3

According to document , you can pass, proxies = None or proxies = {}

urllib.urlopen(some_url, proxies=None)
+1
source

I am having problems with a request that ignores proxies. This did not work.

proxies=None or proxies={} 

It worked

proxies={'http':None}
0
source