requests.exceptions.SSLError: HTTPSConnectionPool(host='', port=443): Max retries exceeded with url: / (Caused by SSLError(SSLEOFError(8, 'EOF occurred in violation of protocol (_ssl.c:1129)')))
原因
urllib3 1.26更新了主架构
proxy = {'https': 'http://127.0.0.1:7890',}
# urllib3 schema旧版proxies ={'http':'http://127.0.0.1:7890','https':'https://127.0.0.1:7890'}
解决方法一:
pip install --upgrade pip
pip install urllib3==1.25.11
解决方法二:
# proxy换成urllib3 1.26格式import requestsurl = '/'proxy = {'https': 'http://127.0.0.1:7890',}headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36'}res = requests.get(url=url, headers=headers, proxies=proxy)print(res.text)