ฉันต้องการเปิดและอ่าน 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()
อย่างไรก็ตาม รหัสต่อไปนี้ที่ใช้ urllib.request
ล้มเหลว:
import urllib.request
opener = urllib.request.build_opener()
resp = opener.open('https://yande.re/')
data = resp.read()
มันทำให้ฉันมีข้อผิดพลาดต่อไปนี้: 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
return opener.open(url, data, timeout)
File "C:\Python32\lib\urllib\request.py", line 369, in open
response = self._open(req, data)
File "C:\Python32\lib\urllib\request.py", line 387, in _open
'_open', req)
File "C:\Python32\lib\urllib\request.py", line 347, in _call_chain
result = func(*args)
File "C:\Python32\lib\urllib\request.py", line 1171, in https_open
context=self._context, check_hostname=self._check_hostname)
File "C:\Python32\lib\urllib\request.py", line 1138, in do_open
raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 1] _ssl.c:392: error:1411809D:SSL routines:SSL_CHECK_SERVERHELLO_TLSEXT:tls invalid ecpointformat list>
>>>
import ssl; ssl.OPENSSL_VERSION
และผลลัพธ์ของurllib.request.urlopen('https://yande.re/')
ได้ไหม - person Burhan Khalid   schedule 21.05.2012conn.request('GET', '/')
- person jfs   schedule 05.09.2012