ResetError: [Errno 104] Connection reset by peer
python request ConnectionResetError: [Errno 104] Connection reset by peer
你请求的url很可能需要代理才能访问
方法1#
安装PySocks
sudo pip3 install PySocks -i https://pypi.tuna.tsinghua.edu.cn/simple
使用代理(本机已经装好了代理,使用1080端口)
import socketimport socksimport requests socks.set_default_proxy(socks.SOCKS5, "127.0.0.1", 1080) socket.socket = socks.socksocket r = requests.get(url) ...
方法2#
import requests proxies = { 'http': 'socks5://127.0.0.1:20808', 'https': 'socks5://127.0.0.1:20808'} r = requests.get(url, proxies=proxies)
评论区
请登陆 后评论!