爬虫 代理 报错 Connection refused
2019-07-24 本文已影响0人
blaze冰叔
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' 即可