I want to visit
https://www.ptt.cc/bbs/Gossiping/index.htmlbut I find it should be over than OpenSSL 1.0.1l so I install brew and upgrade openssl to OpenSSL 1.0.2j 26 Sep 2016, but when I use pycharm to print out and it will return version in OpenSSL 0.9.8zh 14 Jan 2016. I have been reference
Python: SSLError using requests for surveymonkey.combut it's seen not working,and return [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_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))