Python使用代理ProxyHandler出错[WinError 10061] 由于目标计算机积极拒绝,无法连接。

######刚学Python 这是对着案例敲得以下代码, 执行的时候就报错了

from urllib.request import build_opener,ProxyHandler
from urllib.error import URLError
import ssl
ssl._create_default_https_context = ssl._create_unverified_context
url = 'http://www.baidu.com'
proxy_handler = ProxyHandler({
    'http':'http://127.0.0.1:8080',
    'https':'https://127.0.0.1:8080'
})
opener = build_opener(proxy_handler)
try:
    result = opener.open(url)
    html = result.read().decode('utf-8')
    print(html)
except URLError as e:
    print(e.reason)
报的错误

img

在网上也查了好多资料 也试过好多方案 但还是没解决 这个问题该怎么解决呀?

这个代理池要先配置啊在浏览器中,你配了没

加个user-agent头试试看
不行就再换一个代理ip