HTTPSConnectionPool(host='xxxx', port=443): Max retries exceeded with url: /xx/xxx (Caused by ProtocolError('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')))
response = requests.get('https://xxxx', headers=headers,proxies=proxy,verify=False)
这个有两种可能:.http连接太多没有关闭导致的、、、访问次数频繁,被禁止访问
1.http连接太多没有关闭导致的,解决方法:
import requests
requests.adapters.DEFAULT_RETRIES = 5 # 增加重连次数
s = requests.session()
s.keep_alive = False # 关闭多余连接
s.get(url) # 你需要的网址
2.访问次数频繁,被禁止访问,解决方法:使用代理
import requests
s = requests.session()
url = "https://mail.163.com/"
s.proxies = {"https": "47.100.104.247:8080", "http": "36.248.10.47:8080", }
s.headers = header
s.get(url)