Найти - Пользователи
Полная версия: urllib.urlopen https не открывается
Начало » Python для новичков » urllib.urlopen https не открывается
1
URLLIB2
Проблема решена
URLLIB2

>>> import urllib
>>> urllib.urlopen("http://www.xxxx.com")
<addinfourl at 75842120L whose fp = <socket._fileobject object at 0x00000000048442A0>>
всё нормально, но если открывать https, а мне надо именно https, то получается ошибка:
>>> urllib.urlopen("https://www.xxxx.com")
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "D:\Python27\lib\urllib.py", line 84, in urlopen
    return opener.open(url)
  File "D:\Python27\lib\urllib.py", line 205, in open
    return getattr(self, name)(url)
  File "D:\Python27\lib\urllib.py", line 435, in open_https
    h.endheaders(data)
  File "D:\Python27\lib\httplib.py", line 951, in endheaders
    self._send_output(message_body)
  File "D:\Python27\lib\httplib.py", line 811, in _send_output
    self.send(msg)
  File "D:\Python27\lib\httplib.py", line 773, in send
    self.connect()
  File "D:\Python27\lib\httplib.py", line 1158, in connect
    self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file)
  File "D:\Python27\lib\ssl.py", line 372, in wrap_socket
    ciphers=ciphers)
  File "D:\Python27\lib\ssl.py", line 134, in __init__
    self.do_handshake()
  File "D:\Python27\lib\ssl.py", line 296, in do_handshake
    self._sslobj.do_handshake()
IOError: [Errno socket error] [Errno 8] _ssl.c:503: EOF occurred in violation of protocol
py.user.next
на втором то же самое

на третьем
>>> import urllib.request
>>> 
>>> data = urllib.request.urlopen('https://www.indiegala.com')
>>> data.read()[:100]
b'\r\n\r\n\t\t<!doctype html>\r\n\t\t<!--[if lt IE 7 ]><html class="ie ie6" lang="en"> <![endif]-->\r\n\t\t<!--[if I'
>>>
URLLIB2
>>> import urllib.request
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
ImportError: No module named request

У меня ActivePython-2.7.2.5-win64-x64
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB