ConnectionError: ERR#0015: error 406,稍后再试

  • 本文关键字:ERR#0015 error ConnectionError python
  • 更新时间 :
  • 英文 :

ConnectionError                           Traceback (most recent call last)
<ipython-input-9-448d9ab61699> in <module>()
----> 1 bgre = inv.stocks.get_stock_information(stock="BGRE", country="India" )
/usr/local/lib/python3.7/dist-packages/investpy/stocks.py in get_stock_information(stock, country, as_json)
1097 
1098     if req.status_code != 200:
-> 1099         raise ConnectionError("ERR#0015: error " + str(req.status_code) + ", try again later.")
1100 
1101     root_ = fromstring(req.text)
ConnectionError: ERR#0015: error 406, try again later.

它曾经得到执行没有任何错误,但现在我遇到上述错误。有人可以解释这种错误类型是什么,我应该怎么做,在这种情况下执行代码没有任何错误。

根据Mozilla文档,错误406表示

[…服务器无法生成与请求的主动内容协商头中定义的可接受值列表匹配的响应,并且服务器不愿意提供默认表示。

根据Github的Investpy,虽然,这个错误是由于该网站的请求限制。

我认为你需要在发送更多请求之前等待,因为Investing.com限制了你几个小时,所以在发送这些请求之前确保你可以访问https://www.investing.com/equities/没有任何问题。否则,唯一的解决方案是等待😩,下次尝试在每个请求之间等待更多的时间,因为Investing.com对其股票/股票功能的请求有一些严重的限制…

相关内容

最新更新