嗨,我已经写了几行简单的代码。但是我似乎收到了身份验证错误。任何人都可以提出建议,在这里寻找python的凭据是什么?
代码:
import urllib2
response = urllib2.urlopen('http://google.com')
html = response.read()
错误
urllib2.HTTPError: HTTP Error 407: Proxy Authentication Required
PS:我没有访问IE的权限->“高级设置”或 regedit
根据建议,我已经修改了代码:
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()
我还创建了两个环境变量:
HTTP_PROXY = http://username:[email protected]
HTTPS_PROXY = https://username:[email protected]
但是仍然出现错误。
urllib2.HTTPError: HTTP Error 407: Proxy Authentication Required
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句