Proxy authentication error - python -


hi have written few simple lines of code. seem getting authentication error. can please suggest , credentials being looked python here ?

code:

import urllib2 response = urllib2.urlopen('http://google.com') html = response.read() 

error

urllib2.httperror: http error 407: proxy authentication required 

ps: not have acces ie -->advanced settings or regedit

as advised i've modified code :

import urllib2 proxy_support = urllib2.proxyhandler({'http':r'http://usename:psw@ip:port'}) auth = urllib2.httpbasicauthhandler() opener = urllib2.build_opener(proxy_support, auth, urllib2.httphandler) urllib2.install_opener(opener) response = urllib2.urlopen('http://google.com') html = response.read() 

also have created 2 environment variables :

http_proxy = http://username:password@proxyserver.domain.com https_proxy = https://username:password@proxyserver.domain.com 

but still getting error .

urllib2.httperror: http error 407: proxy authentication required

there multiple ways work-around problem. may want try defining environment variables names http_proxy , https_proxy each set proxy url. refer this link more details.

alternatively, may want explicitly define proxyhandler work urllib2 while handling requests through proxy. link present within comment query; including here sake of completeness.

hope helps


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 -