check_hostname requires server_hostname报错

问题原因

urllib3的1.26.4版本有个bug
https://github.com/urllib3/urllib3/issues/517

解决办法

  1. urllib3降低版本:urllib3==1.25.7

  2. request方法加上verify=False参数
    response = requests.request('GET', 'https://httpbin.org/get', verify=False)
    直接运行会报下面的警告:

InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings InsecureRequestWarning,

  1. 在request请求前面要加上下面的代码,可以解决上面的警告
requests.packages.urllib3.disable_warnings()

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-03
  • 2022-01-08
猜你喜欢
  • 2022-12-23
  • 2021-06-14
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-09-10
相关资源
相似解决方案