Search code examples
regexpython-2.7windows-8

IOError: [Errno socket error] [Errno 1] _ssl.c:507: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol


below is my code i am using to scrap some web page i am using python in windows 8

import urllib
import re

htmlfile = urllib.urlopen("https://finance.yahoo.com/q?s=aapl&ql=1")
htmltext = htmlfile.read()

regex='<span id="yfs_l84_aapl">(.+?)</span>'

pattern = re.compile(regex)
price = re.findall(pattern,htmltext)
print price

error i am getting

Traceback (most recent call last): File "C:\Python27\web.py", line 4, in htmlfile = urllib.urlopen("https://finance.yahoo.com/q?s=aapl&ql=1") File "C:\Python27\lib\urllib.py", line 87, in urlopen return opener.open(url) File "C:\Python27\lib\urllib.py", line 208, in open return getattr(self, name)(url) File "C:\Python27\lib\urllib.py", line 437, in open_https h.endheaders(data) File "C:\Python27\lib\httplib.py", line 969, in endheaders self._send_output(message_body) File "C:\Python27\lib\httplib.py", line 829, in _send_output self.send(msg) File "C:\Python27\lib\httplib.py", line 791, in send self.connect() File "C:\Python27\lib\httplib.py", line 1176, in connect self.sock = ssl.wrap_socket(sock, self.key_file, self.cert_file) File "C:\Python27\lib\ssl.py", line 387, in wrap_socket ciphers=ciphers) File "C:\Python27\lib\ssl.py", line 143, in init self.do_handshake() File "C:\Python27\lib\ssl.py", line 305, in do_handshake self._sslobj.do_handshake() IOError: [Errno socket error] [Errno 1] _ssl.c:507: error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol

how to debug this error


Solution

  • use inspect element > go to console > check if any errors in script > manage them > if problem still persists go to network option > now reload the page and check the flow of information > and rebuilt where info. flow is stopped or unexpected.

    hope this will solve your problem.