Python:在windows上执行而不是在linux上执行时,获取请求时握手错误

我写了一个python脚本来下载一个网站的内容,当我在一台linux机器上执行它,而不是在windows上(它需要在Windows上执行),它工作得很好。

这是产生错误的代码:

import requests c = requests.Session() url = 'https://ted.jeancoutu.com/action/login' c.get(url) 

这是我在Windows机器上执行代码时得到的错误消息:

 Traceback (most recent call last): File "C:\Python34\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 348, in ssl_wrap_socket cnx.do_handshake() File "C:\Python34\lib\site-packages\OpenSSL\SSL.py", line 1443, in do_handshake self._raise_ssl_error(self._ssl, result) File "C:\Python34\lib\site-packages\OpenSSL\SSL.py", line 1191, in _raise_ssl_error _raise_current_error() File "C:\Python34\lib\site-packages\OpenSSL\_util.py", line 48, in exception_from_error_queue raise exception_type(errors) OpenSSL.SSL.Error: [('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')] During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 578, in urlopen chunked=chunked) File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 351, in _make_request self._validate_conn(conn) File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 814, in _validate_conn conn.connect() File "C:\Python34\lib\site-packages\requests\packages\urllib3\connection.py", line 289, in connect ssl_version=resolved_ssl_version) File "C:\Python34\lib\site-packages\requests\packages\urllib3\contrib\pyopenssl.py", line 355, in ssl_wrap_socket raise ssl.SSLError('bad handshake: %r' % e) ssl.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Python34\lib\site-packages\requests\adapters.py", line 403, in send timeout=timeout File "C:\Python34\lib\site-packages\requests\packages\urllib3\connectionpool.py", line 604, in urlopen raise SSLError(e) requests.packages.urllib3.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",) During handling of the above exception, another exception occurred: Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python34\lib\site-packages\requests\sessions.py", line 487, in get return self.request('GET', url, **kwargs) File "C:\Python34\lib\site-packages\requests\sessions.py", line 475, in request resp = self.send(prep, **send_kwargs) File "C:\Python34\lib\site-packages\requests\sessions.py", line 585, in send r = adapter.send(request, **kwargs) File "C:\Python34\lib\site-packages\requests\adapters.py", line 477, in send raise SSLError(e, request=request) requests.exceptions.SSLError: ("bad handshake: Error([('SSL routines', 'SSL23_GET_SERVER_HELLO', 'sslv3 alert handshake failure')],)",) 

我找不到解决这个问题的办法。 我尝试了很多我在网上find的build议,但是没有成功 我安装了pyOpenSSL,ndg-httpsclient和pyasn1没有结果。 我也升级了SSL,但还是一无所获。

谢谢你的build议

ted.jeancoutu.com网站仅支持RC4-SHA和RC4-MD5密码(请参阅SSLLabs报告 ,RC4密码被认为是不安全的,因此从2015年2月发布的2.5.2版本的默认密码中删除 。可能在Linux上使用旧版本的请求,所以它仍然可以工作,但是在Windows上使用较新的版本会失败。

请参阅https://stackoverflow.com/a/32651967/3081018了解如何通过启用不安全的密码来解决此问题&#x3002;