check_hostname requires server_hostname报错

作者:@sonny-zhang
本文为作者原创,转载请注明出处:https://www.cnblogs.com/1fengchen1/p/14545388.html


目录

问题截图

问题原因

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()
(0)

相关推荐