requests.exceptions.SSLError: HTTPSConnectionPool(host='cn.bing.com', port=443)报错解决方

2021-02-12 12:22

阅读:475

标签:sel   import   ror   htm   dog   failed   请求   gecko   请求头   

一、问题描述

运行以下代码

#!/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)报错解决方案

标签:sel   import   ror   htm   dog   failed   请求   gecko   请求头   

原文地址:https://www.cnblogs.com/lxmtx/p/13030406.html


评论


亲,登录后才可以留言!