使用python 3.2.2
按照文档示例,如下:
authinfo = urllib.request.HTTPBasicAuthHandler()
authinfo.add_password(realm='PDQ Application',
uri='https://mahler:8092/site-updates.py',
user='klem',
passwd='geheim$parole')
proxy_support = urllib.request.ProxyHandler({"http" : "http://ahad-haam:3128"})
# build a new opener that adds authentication and caching FTP handlers
opener = urllib.request.build_opener(proxy_support, authinfo,
urllib.request.CacheFTPHandler)
# install it
urllib.request.install_opener(opener)
f = urllib.request.urlopen('http://www.python.org/')
访问的时候报
Traceback (most recent call last):
File "", line 1, in
File "D:\Python\Python32\lib\urllib\request.py", line 138, in urlopen
return opener.open(url, data, timeout)
File "D:\Python\Python32\lib\urllib\request.py", line 375, in open
response = meth(req, response)
File "D:\Python\Python32\lib\urllib\request.py", line 487, in http_response
'http', request, response, code, msg, hdrs)
File "D:\Python\Python32\lib\urllib\request.py", line 413, in error
return self._call_chain(*args)
File "D:\Python\Python32\lib\urllib\request.py", line 347, in _call_chain
result = func(*args)
File "D:\Python\Python32\lib\urllib\request.py", line 495, in http_error_default
raise HTTPError(req.full_url, code, msg, hdrs, fp)
urllib.error.HTTPError: HTTP Error 407: Proxy Authentication Required
有谁知道怎么解决吗?