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()
posted @ 2021-03-16 19:29  SonnyZhang  阅读(20937)  评论(4编辑  收藏  举报