proxy_handler = ProxyHandler({
    'http':'http://127.0.0.1:9743',
    'https':'http://127.0.0.1:9743'
})
opener = build_opener(proxy_handler)
try:
    response = opener.open('https://www.baidu.com')
    print(response.read().decode('utf-8'))
except URLError as e:
    print('throw error: %s' % e.reason)
throw error: [Errno 61] Connection refused

删除 ‘https’:’http://127.0.0.1:9743′ 即可

文章来源于互联网:爬虫 代理 报错 Connection refused

发表评论