python - urllib2.ProxyHandler - query -


definition :

urllib2.proxyhandler([proxies]) 

cause requests go through proxy. if proxies given, must dictionary mapping protocol names urls of proxies. default read list of proxies environment variables _proxy. if no proxy environment variables set, in windows environment proxy settings obtained registry’s internet settings section, , in mac os x environment proxy information retrieved os x system configuration framework.

my understanding , if proxy not set explicity detects proxy registry settings .

buet when run below code:

import urllib2 proxy_support = urllib2.proxyhandler({}) print "1" opener = urllib2.build_opener(proxy_support) print "2" urllib2.install_opener(opener) print "3" response = urllib2.urlopen('http://google.com') print "4" html = response.read() 

i error :

1 2 3 urllib2.urlerror: <urlopen error [errno 10060] connection attempt failed because connected party did not respond after period of time, or established connection failed because connected host has failed respond> 

this means the piece of code not able open website . not sure going wrong , shouldn't per definition , urllib2.proxyhandler , proxy off registry , since haven't explicitly set proxy ?

shouldn't per definition , urllib2.proxyhandler , proxy off registry , since haven't explicitly set proxy ?

but have explicitly set proxy {}. docs say:

to disable autodetected proxy pass empty dictionary.

instead of this:

proxy_support = urllib2.proxyhandler({}) 

you need this:

proxy_support = urllib2.proxyhandler() 

Comments

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -