Python 3.5使用OpenSSL错误([SSL:SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3警报握手失败(_ssl.c:645))

时间:2016-11-09 04:30:16

标签: macos python-3.x homebrew pyopenssl

我想访问

https://www.ptt.cc/bbs/Gossiping/index.html
但我发现它应该超过OpenSSL 1.0.1l 所以我安装brew并将openssl升级到OpenSSL 1.0.2j 2016年9月26日, 但是当我使用pycharm打印出来并且它将在2016年1月14日的OpenSSL 0.9.8zh中返回版本。我已经参考
Python: SSLError using requests for surveymonkey.com
但它看起来不起作用,并返回 [SSL:SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3警报握手失败(_ssl.c:645)

import urllib3
import urllib3.request
import requests
import ssl
import requests.packages.urllib3.util.ssl_
requests.packages.urllib3.util.ssl_.DEFAULT_CIPHERS = 'ALL'
try:
    links = ['https://www.ptt.cc/bbs/Gossiping/index' + str(id + 1) + '.html' 
    for id in range(15156)]
    twice_link = []
    data = {"yes": "yes"}
    head = {"User-gent": "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0"}
    for ind, link in enumerate(links, 0):
       with requests.Session() as s:
          data["from"] = "/bbs/Gossiping/index{}.html".format(ind)
          s.post("https://www.ptt.cc/ask/over18", data=data, headers=head)
          res = s.get(link, headers=head)
          soup = BeautifulSoup(res.content,"html.parser")
          data_title = soup.select("div.title")
          data_date = soup.select("div.date") 
          data_author =soup.select("div.author")  
          data_times = soup.select("div.nrec")  
except Exception as e:
    print(ssl.OPENSSL_VERSION)
    print(str(e))

0 个答案:

没有答案