【问题标题】:requests in python get error WSAECONNRESETpython中的请求得到错误WSAECONNRESET
【发布时间】:2021-09-10 04:58:15
【问题描述】:

我正在尝试通过请求获取汇率:

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

我收到一个错误: {ConnectionError}('连接中止。', OSError("(10054, 'WSAECONNRESET')"))

该错误的解决方案是什么?

【问题讨论】:

    标签: python python-2.7 python-requests oserror


    【解决方案1】:

    服务器会检查有效/支持的浏览器。您需要传递一个它接受的参数,例如

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

    【讨论】:

      猜你喜欢
      • 2018-06-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-26
      • 1970-01-01
      • 1970-01-01
      • 2021-08-08
      • 1970-01-01
      相关资源
      最近更新 更多