Error downloading a file using python package requests with https -
i'm begginer in python , have been struggling downloading file using package requests. code works url http, not https. code following:
import requests url = 'https://firms.modaps.eosdis.nasa.gov/active_fire/shapes/zips/central_america_24h.zip' print "downloading requests" r = requests.get(url) open("central_america_24h.zip", "wb") code: code.write(r.content)
i following errors:
warning (from warnings module): file "c:\python27\arcgis10.1\lib\site-packages\requests\packages\urllib3\util\ssl_.py", line 90 insecureplatformwarning insecureplatformwarning: true sslcontext object not available. prevents urllib3 configuring ssl appropriately , may cause ssl connections fail. more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning. traceback (most recent call last): file "c:\users\lmixco\downloads\descarga.py", line 8, in <module> r = requests.get(url) file "c:\python27\arcgis10.1\lib\site-packages\requests\api.py", line 68, in return request('get', url, **kwargs) file "c:\python27\arcgis10.1\lib\site-packages\requests\api.py", line 50, in request response = session.request(method=method, url=url, **kwargs) file "c:\python27\arcgis10.1\lib\site-packages\requests\sessions.py", line 465, in request resp = self.send(prep, **send_kwargs) file "c:\python27\arcgis10.1\lib\site-packages\requests\sessions.py", line 594, in send history = [resp resp in gen] if allow_redirects else [] file "c:\python27\arcgis10.1\lib\site-packages\requests\sessions.py", line 196, in resolve_redirects **adapter_kwargs file "c:\python27\arcgis10.1\lib\site-packages\requests\sessions.py", line 573, in send r = adapter.send(request, **kwargs) file "c:\python27\arcgis10.1\lib\site-packages\requests\adapters.py", line 431, in send raise sslerror(e, request=request) sslerror: [errno 8] _ssl.c:503: eof occurred in violation of protocol
i have been looking solution, have not found anything. appreciated. in advance.
you need install package , use this
pip install requests[security]
for debain / ubuntu , install before installing above package
apt-get install python-dev libffi-dev libssl-dev
Comments
Post a Comment