python requests 通过代理方式请求https网站时,出现错误:
(SSLError("bad handshake: Error([('SSL routines', 'ssl3_get_record', 'wrong version number')],)",),))
网上大部分解决办法都是无效的,不过还是找到了一篇靠谱的:https://blog.csdn.net/qq_37049050/article/details/76649005
也就是说https网站所用的SSL协议版本太低,而python解释器所用的SSL协议版本高于https网站所用的SSL协议版本,所以出现问题。
解决办法就是手动配置python,使requests选择更低版本的SSL协议。
首先在python脚本开头引入SSL适配器,如下:
from requests_toolbelt import SSLAdapter
然后加载低版本的SSL协议,如下:
self.session.mount(‘https://’, SSLAdapter(‘TLSv1’))
发表回复