Search code examples
pythonpython-2.7python-requestsoserror

requests in python get error WSAECONNRESET


I'm trying to get exchange rate with a request:

r = requests.get('https://www.boi.org.il/currency.xml?curr=01')

I'm getting an error : {ConnectionError}('Connection aborted.', OSError("(10054, 'WSAECONNRESET')"))

What is the solution for that error?


Solution

  • The server does a check for valid/supported browsers. You need to pass one it accepts e.g.

    import requests
    
    headers = {'User-Agent': 'Safari/537.36'}
    r = requests.get('https://www.boi.org.il/currency.xml?curr=01', headers=headers)