requests.exceptions.SSLError: HTTPSConnectionPool(host='cn.bing.com', port=443)报错解决方案
Posted lxmtx
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了requests.exceptions.SSLError: HTTPSConnectionPool(host='cn.bing.com', port=443)报错解决方案相关的知识,希望对你有一定的参考价值。
一、问题描述
运行以下代码
#!/usr/local/bin/python3.7 import requests import ssl # 请求url url = ‘https://cn.bing.com/tlookupv3?isVertical=1&&IG=1E1AE90B09BB41E28506E0ADC9E45704&IID=translator.5028.2‘ # 请求头 headers = { ‘User-Agent‘:‘Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_4) AppleWebKit/537.36 (Khtml, like Gecko) Chrome/80.0.3987.163 Safari/537.36‘ } # 请求formdata formdata = { ‘from‘: ‘en‘, ‘to‘: ‘zh-Hans‘, ‘text‘: ‘dog‘ } # 发送请求 r = requests.post(url, headers=headers, data=formdata) print(r.json())
报错如下:
requests.exceptions.SSLError: HTTPSConnectionPool(host=‘cn.bing.com‘, port=443): Max retries exceeded with url: /tlookupv3?isVertical=1&&IG=1E1AE90B09BB41E28506E0ADC9E45704&IID=translator.5028.2 (Caused by SSLError(SSLCertVerificationError(1, ‘[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1076)‘)))
二、报错原因
电脑连打开了代理
三、解决方案
关闭代理即可。
以上是关于requests.exceptions.SSLError: HTTPSConnectionPool(host='cn.bing.com', port=443)报错解决方案的主要内容,如果未能解决你的问题,请参考以下文章