一、问题描述

运行以下代码

#!/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)')))

二、报错原因

  电脑连打开了代理

三、解决方案

  关闭代理即可。

相关文章:

  • 2021-07-11
  • 2022-12-23
  • 2021-05-30
  • 2021-09-07
  • 2021-04-09
  • 2022-12-23
  • 2022-01-30
  • 2022-01-16
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-30
相关资源
相似解决方案