我想打开并阅读https://yande.re/用urllib.request,但我发现了一个SSL错误.我可以使用http.client以下代码打开并阅读页面:
import http.client
conn = http.client.HTTPSConnection('www.yande.re')
conn.request('GET', 'https://yande.re/')
resp = conn.getresponse()
data = resp.read()
Run Code Online (Sandbox Code Playgroud)
但是,以下代码使用urllib.request失败:
import urllib.request
opener = urllib.request.build_opener()
resp = opener.open('https://yande.re/')
data = resp.read()
Run Code Online (Sandbox Code Playgroud)
它给了我以下错误:ssl.SSLError: [Errno 1] _ssl.c:392: error:1411809D:SSL routines:SSL_CHECK_SERVERHELLO_TLSEXT:tls invalid ecpointformat list.为什么我可以使用HTTPSConnection而不是opener.open打开页面?
编辑:这是我的OpenSSL版本和尝试打开的追溯https://yande.re/
>>> import ssl; ssl.OPENSSL_VERSION
'OpenSSL 1.0.0a 1 Jun 2010'
>>> import urllib.request
>>> urllib.request.urlopen('https://yande.re/')
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
urllib.request.urlopen('https://yande.re/')
File "C:\Python32\lib\urllib\request.py", line 138, in urlopen …Run Code Online (Sandbox Code Playgroud)