Python 3.x HTTP错误502:无法访问父代理

Python 3.x HTTP错误502:无法访问父代理,python-3.x,https,proxy,httprequest,urllib,Python 3.x,Https,Proxy,Httprequest,Urllib,我已经使用CNTLM完成了代理设置,并且有一个脚本(google.py)来检查代理设置是否正常工作 import urllib.request proxy_support = urllib.request.ProxyHandler({"http":"http://localhost:3128"}) opener = urllib.request.build_opener(proxy_support) urllib.request.install_opener(opener) html = url

我已经使用CNTLM完成了代理设置,并且有一个脚本(google.py)来检查代理设置是否正常工作

import urllib.request
proxy_support = urllib.request.ProxyHandler({"http":"http://localhost:3128"})
opener = urllib.request.build_opener(proxy_support)
urllib.request.install_opener(opener)
html = urllib.request.urlopen("http://www.google.com").read()
print(html)
当我运行脚本时,我得到以下错误

C:\Users\asj5cob\Desktop>py -3.4 google.py
Traceback (most recent call last):
  File "google.py", line 5, in <module>
    html = urllib.request.urlopen("http://www.google.com").read()
  File "C:\Python34\lib\urllib\request.py", line 161, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Python34\lib\urllib\request.py", line 470, in open
    response = meth(req, response)
  File "C:\Python34\lib\urllib\request.py", line 580, in http_response
    'http', request, response, code, msg, hdrs)
  File "C:\Python34\lib\urllib\request.py", line 508, in error
    return self._call_chain(*args)
  File "C:\Python34\lib\urllib\request.py", line 442, in _call_chain
    result = func(*args)
  File "C:\Python34\lib\urllib\request.py", line 588, in http_error_default
    raise HTTPError(req.full_url, code, msg, hdrs, fp)
 urllib.error.HTTPError: HTTP Error 502: Parent proxy unreacheable
C:\Users\asj5cob\Desktop>py-3.4google.py
回溯(最近一次呼叫最后一次):
文件“google.py”,第5行,在
html=urllib.request.urlopen(“http://www.google.com)改为
文件“C:\Python34\lib\urllib\request.py”,第161行,在urlopen中
返回opener.open(url、数据、超时)
打开文件“C:\Python34\lib\urllib\request.py”,第470行
响应=方法(请求,响应)
文件“C:\Python34\lib\urllib\request.py”,第580行,在http\U响应中
“http”、请求、响应、代码、消息、hdrs)
文件“C:\Python34\lib\urllib\request.py”第508行出错
返回自我。调用链(*args)
文件“C:\Python34\lib\urllib\request.py”,第442行,在调用链中
结果=func(*args)
文件“C:\Python34\lib\urllib\request.py”,第588行,默认为http\u error\u
raise HTTPError(请求完整的url、代码、消息、hdrs、fp)
urllib.error.HTTPError:HTTP错误502:父代理不可检查

是否通过在管理员命令窗口中执行来启动CNTLM

net start cntlm

是否通过在管理员命令窗口中执行来启动CNTLM

net start cntlm