I have the following curl, which I need it to work from python using the requests package.
curl -s -H 'Accept: application/xml' 'https://xyz.com'
I tried the following with no success. Can you see what am I doing wrong here?
headers = {'Accept': 'application/xml'}
print requests.get("https://xyz.com", headers=headers)
After some seconds I get this:
print requests.get("https://xyz.com", headers=headers)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 55, in get
return request('get', url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/api.py", line 44, in request
return session.request(method=method, url=url, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 383, in request
resp = self.send(prep, **send_kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/sessions.py", line 486, in send
r = adapter.send(request, **kwargs)
File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/requests/adapters.py", line 389, in send
raise SSLError(e)
requests.exceptions.SSLError: [Errno 8] _ssl.c:504: EOF occurred in violation of protocol
Fix: The calls weren't equivalent because the curl call was http, whereas the requests call was https.