I was trying to download a PDF file from Internet and Python2.7.15cr1 and requests 2.19.1 but I am facing this error:
> Traceback (most recent call last):
> File "download.py", line 5, in <module>
> r = requests.get(url,verify=False)
> File "/home/user/.local/lib/python2.7/site-packages/requests/api.py",
> line 72, in get
> return request('get', url, params=params, **kwargs)
> File "/home/user/.local/lib/python2.7/site-packages/requests/api.py",
> line 58, in request
> return session.request(method=method, url=url, **kwargs)
> File "/home/user/.local/lib/python2.7/site-packages/requests/sessions.py",
> line 512, in request
> resp = self.send(prep, **send_kwargs)
> File "/home/user/.local/lib/python2.7/site-packages/requests/sessions.py",
> line 622, in send
> r = adapter.send(request, **kwargs)
> File "/home/user/.local/lib/python2.7/site-packages/requests/adapters.py",
> line 511, in send
> raise SSLError(e, request=request)
> requests.exceptions.SSLError: HTTPSConnectionPool(host='host', port=443): Max
> retries exceeded with url: /en/files/pdftodownload.pdf
> (Caused by SSLError(SSLError("bad handshake: Error([('SSL routines',
> 'ssl3_read_bytes', 'sslv3 alert handshake failure')],)",),))
The code that I'm using to trying to download a PDF file is:
import requests
url = 'https://www.gasnaturalfenosa.com/en/files/GasNaturalSDG_ing_2016-2.pdf'
r = requests.get(url, stream=True)
with open('metadata.pdf', 'wb') as fd:
for chunk in r.iter_content(chunk_size=2048):
fd.write(chunk)
If I try to download it using curl I got the same error. I've been trying to fix this error for several days, so I'll be very grateful if someone could give me a hint of why this is happening!!
Thank you in advance!