0

I'm the total freshman of python.And when I tried to draw simple codes of Crawler software to seize some info from website, there are some errors showed in halfway of coding, could someone help me to figure it out?

import httplib
connection = httplib.HTTPSConnection('jsonplaceholder.typicode.com')
connection.request('GET', '/posts')

the followings are the errors:

Traceback (most recent call last):
  File "<pyshell#3>", line 1, in <module>
    connection.request('GET', '/posts')
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1042, in request
    self._send_request(method, url, body, headers)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1082, in _send_request
    self.endheaders(body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1038, in endheaders
    self._send_output(message_body)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 882, in _send_output
    self.send(msg)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 844, in send
    self.connect()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/httplib.py", line 1263, in connect
    server_hostname=server_hostname)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 363, in wrap_socket
    _context=self)
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 611, in __init__
    self.do_handshake()
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/ssl.py", line 840, in do_handshake
    self._sslobj.do_handshake()
SSLError: [SSL: SSLV3_ALERT_HANDSHAKE_FAILURE] sslv3 alert handshake failure (_ssl.c:661)
anthony sottile
  • 61,815
  • 15
  • 148
  • 207
Jeff Hoffman
  • 71
  • 1
  • 2
  • 9
  • after these 3 lines of codes , I will do resp = conn.getresponse() and data=resp.read(0 – Jeff Hoffman Jul 06 '17 at 21:14
  • I'm going to mark as duplicate, but before I do so I'll add some additional information -- the site you are trying to load does not support SSLV1 (only TLS1.x), your python (given osx) is probably compiled against old libssl libraries. [Here's the ssl report for that domain](https://www.ssllabs.com/ssltest/analyze.html?d=jsonplaceholder.typicode.com&s=104.31.86.157&latest) – anthony sottile Jul 07 '17 at 02:42

0 Answers0