Python请求-尝试获取presto文档返回sslv3警报握手失败

Python请求-尝试获取presto文档返回sslv3警报握手失败,python,python-requests,Python,Python Requests,我正在尝试使用Python请求获取一些分析的内容: import requests requests.get('https://prestodb.io/docs/current/functions/logical.html') 这将返回以下错误: File "/Users/my_user/PycharmProjects/untitled/test.py", line 3, in <module> requests.get('https://prestodb.io/doc

我正在尝试使用Python请求获取一些分析的内容:

import requests
requests.get('https://prestodb.io/docs/current/functions/logical.html')
这将返回以下错误:

  File "/Users/my_user/PycharmProjects/untitled/test.py", line 3, in <module>
    requests.get('https://prestodb.io/docs/current/functions/logical.html')
  File "/Library/Python/2.7/site-packages/requests/api.py", line 71, in get
    return request('get', url, params=params, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/api.py", line 57, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 475, in request
    resp = self.send(prep, **send_kwargs)
  File "/Library/Python/2.7/site-packages/requests/sessions.py", line 585, in send
    r = adapter.send(request, **kwargs)
  File "/Library/Python/2.7/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')],)",)
我做了很多搜索,并尝试了其他方法:
  • 我已经尝试使用一个定制的HTTPAdapter来指定协议为TLSv1,但是没有帮助
  • 我也尝试过直接使用SSL上下文和连接对象并设置\u tlsext\u host\u名称,但也没有任何帮助。

  • 在我看来,要求是使用TLSv1和SNI。但我无法通过请求获得这些信息。有人能帮我解决这个问题吗?提前感谢。

    感谢卢卡斯·格拉夫和我基于。我实际做的是从Homebrew安装OpenSSL,然后从Homebrew安装Python 2的新版本,该版本将自动链接到Homebrew提供的OpenSSL:

    brew install openssl
    brew install python
    

    使用新安装的python,我可以获得presto文档页面。

    您正在运行的python 2.7的确切版本是什么?如果你低于2.7.9,你需要用
    [security]
    额外的
    来安装
    请求
    ,以获得SNI支持(例如
    pip安装请求[security]
    )。我在跑2.7.10。我尝试了额外的安全措施,但似乎没有效果。我会检查你提到的问题。再次感谢。@LukasGraf您发送的问题我已经讨论了一半,它解决了我的问题。基本上,我(重新)安装了openssl和python使用自制。谢谢!不客气,很高兴我能帮上忙:)如果你能把对你有用的步骤更详细地作为一个例子发布,我很乐意投上一票。
    brew install openssl
    brew install python