-1

I'm using Python and I'm trying to scrape this website: https://online.ratb.ro/info/browsers.aspx

But I'm getting this error:

Traceback (most recent call last):
File "C:\Users\pinguluk\Desktop\Proiecte GIT\RATB Scraper\test2.py", line 3, in
test = requests.get('https://online.ratb.ro/info/browsers.aspx')
File "C:\Python27\lib\site-packages\requests\api.py", line 72, in get
return request('get', url, params=params, **kwargs)
File "C:\Python27\lib\site-packages\requests\api.py", line 58, in request
return session.request(method=method, url=url, **kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 518, in request
resp = self.send(prep, **send_kwargs)
File "C:\Python27\lib\site-packages\requests\sessions.py", line 639, in send
r = adapter.send(request, **kwargs)
File "C:\Python27\lib\site-packages\requests\adapters.py", line 512, in send
raise SSLError(e, request=request)
requests.exceptions.SSLError: ("bad handshake: SysCallError(-1, 'Unexpected EOF')",)

Installed modules:

['appdirs==1.4.3', 'asn1crypto==0.22.0', 'attrs==16.3.0', 'automat==0.5.0', 'beautifulsoup4==4.5.3', 'cairocffi==0.8.0', 'certifi==2017.4.17', 'cffi==1.10.0', 'colorama==0.3.9', 'constantly==15.1.0', 'cryptography==1.8.1', 'cssselect==1.0.1', 'cycler==0.10.0', 'distributedlock==1.2', 'django-annoying==0.10.3', 'django-oauth-tokens==0.6.3', 'django-taggit==0.22.1', 'django==1.11.1', 'enum34==1.1.6', 'facepy==1.0.8', 'functools32==3.2.3.post2', 'futures==3.1.1', 'gevent==1.2.1', 'greenlet==0.4.12', 'grequests==0.3.0', 'html5lib==0.999999999', 'htmlparser==0.0.2', 'httplib2==0.10.3', 'idna==2.5', 'incremental==16.10.1', 'ipaddress==1.0.18', 'lazyme==0.0.10', 'lxml==3.7.3', 'matplotlib==2.0.2', 'mechanize==0.3.3', 'ndg-httpsclient==0.4.2', 'numpy==1.12.1', 'oauthlib==2.0.2', 'olefile==0.44', 'opencv-python==3.2.0.7', 'packaging==16.8', 'parsel==1.1.0', 'pillow==4.0.0', 'pip==9.0.1', 'py2exe==0.6.9', 'pyandoc==0.0.1', 'pyasn1-modules==0.0.8', 'pyasn1==0.2.3', 'pycairo-gtk==1.10.0', 'pycparser==2.17', 'pygtk==2.22.0', 'pyhook==1.5.1', 'pynput==1.3.2', 'pyopenssl==17.0.0', 'pyparsing==2.2.0', 'pypiwin32==219', 'pyquery==1.2.17', 'python-dateutil==2.6.0', 'python-memcached==1.58', 'pytz==2017.2', 'pywin32==221', 'queuelib==1.4.2', 'requests-futures==0.9.7', 'requests-oauthlib==0.8.0', 'requests-toolbelt==0.8.0', 'requests==2.14.2', 'restclient==0.11.0', 'robobrowser==0.5.3', 'selenium==3.4.1', 'service-identity==16.0.0', 'setuptools==35.0.2', 'simplejson==3.10.0', 'six==1.10.0', 'twitter==1.17.0', 'twitterfollowbot==2.0.2', 'urllib3==1.21.1', 'w3lib==1.17.0', 'webencodings==0.5.1', 'werkzeug==0.12.1', 'wheel==0.29.0', 'zope.interface==4.3.3']

Thanks.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
Pinguluk
  • 54
  • 7
  • This is a similar problem to [Requests failing to connect to a TLS server](https://stackoverflow.com/questions/44141655/requests-failing-to-connect-to-a-tls-server/44142250#44142250) and the same solution of explicitly setting the cipher to 3DES should work. – Steffen Ullrich May 25 '17 at 05:00
  • @SteffenUllrich Thank you so much! Now it works (on Python 3). Just a question, how can I configure it for Python 2 version? – Pinguluk May 25 '17 at 09:03
  • This works for me with Python 2 too. But it might be that you are using a version of openssl which is built without support for 3DES, like openssl 1.1.0. Check `ssl.OPENSSL_VERSION`. In this case you would need to rebuild it with 3DES support. – Steffen Ullrich May 25 '17 at 09:51

2 Answers2

0

I think you will have hard time solving this problem since the server you are trying to "scrape" is awfully configured (ssllabs.com gave it a grade F) and it might be that Requests don't even support any of cipher suites because they are all insecure. There might be an option of creating a custom HTTPAdapter, so you might try that out.

errata
  • 5,695
  • 10
  • 54
  • 99
  • thanks for the tip about sslabs! i managed to get it working using python 3 (i was using 2.7) and i used this method and now it works! https://stackoverflow.com/questions/44141655/requests-failing-to-connect-to-a-tls-server/44142250#44142250 – Pinguluk May 25 '17 at 09:02
  • Yeah, that's similar to what I suggested :) As mentioned over there, if you want to do it 'properly' you will end up with writing your custom HTTPAdapter... – errata May 25 '17 at 09:29
0

You can try using: requests.get(url, verify=False) if you don't need to check the authenticity of the SSL certificate.

Bianca Rosa
  • 197
  • 1
  • 3
  • 10
  • tried, but not working, i solved via this method: https://stackoverflow.com/questions/44141655/requests-failing-to-connect-to-a-tls-server/44142250#44142250 – Pinguluk May 25 '17 at 09:00