Yahoo_fin库是否最近有更新;我收到一个断言错误?

huangapple go评论67阅读模式
英文:

Has there been a recent update to the yahoo_fin library; I'm getting an assertion error?

问题

I've translated the content you provided:

我已经使用了yahoo_fin库好几周了(与2021年的同一版本,没有新的更新)。我的程序现在不工作了,但简单的请求也不工作。我收到了一个断言错误。

以下是我正在尝试使用的基本代码。

from yahoo_fin.stock_info import *

symbol = 'C'
data = get_quote_data(symbol)
print(data)

当我访问源库时,我尝试提取它使用的URL,但那也不起作用。我尝试了多个来自最知名的股票的标记。

site = "https://query1.finance.yahoo.com/v7/finance/quote?symbols=" + ticker

这是返回的内容:

{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}
英文:

I've been using the yahoo_fin library for several weeks (the same version from 2021 with no new updates). My program doesn't work now, but neither does a simple request. I'm getting an assertion error.

Traceback (most recent call last):
  File "C:/Users/Notebook/PycharmProjects/Jarvis/ChatExample.py", line 7, in <module>
    data = get_quote_data(symbol)
  File "C:\Users\Notebook\AppData\Local\Programs\Python\Python37-32\lib\site-packages\yahoo_fin\stock_info.py", line 961, in get_quote_data
    valid.""")
AssertionError: Invalid response from server.  Check if ticker is
                              valid.

Here is the basic code I'm trying to work with.

from yahoo_fin.stock_info import *

symbol = 'C'
data = get_quote_data(symbol)
print(data)

When I go to the source library, I've tried extracting just the URL it uses and that doesn't work either. I've tried multiple stickers from the most well known stocks.

site = "https://query1.finance.yahoo.com/v7/finance/quote?symbols=" + ticker

This is the return:

{"finance":{"result":null,"error":{"code":"Unauthorized","description":"Invalid Crumb"}}}

答案1

得分: 1

将你的网址中的v7改为v6,它应该可以工作,至少暂时是这样。我在GitHub上搜索错误时找到了这个解决方案。

英文:

Change v7 in your URL to v6 and it should work, at least for now. I found this solution on GitHub searching on the error.

答案2

得分: 1

Just use this instead.

site = "https://query2.finance.yahoo.com/v10/finance/quoteSummary/" + ticker + "?modules=summaryDetail"

英文:

Just use this instead.

site = "https://query2.finance.yahoo.com/v10/finance/quoteSummary/" + ticker + "?modules=summaryDetail" 

答案3

得分: 0

I've contacted the author on LinkedIn and he will be updating the library in the next couple of weeks.

I'm using Pycharm, so when I get the error, I'm also given a hyperlink to the error:

File "C:\Users\Notebook\AppData\Local\Programs\Python\Python37-32\lib\site-packages\yahoo_fin\stock_info.py", line 961, in get_quote_data

Click on that link and it should take you the library package and you can do what Dan G mentioned above by changing the V7 in the link to V6 as shown below.

site = "https://query1.finance.yahoo.com/v6/finance/quote?symbols=" + ticker
英文:

I've contacted the author on LinkedIn and he will be updating the library in the next couple of weeks.

I'm using Pycharm, so when I get the error, I'm also given a hyperlink to the error:

File "C:\Users\Notebook\AppData\Local\Programs\Python\Python37-32\lib\site-packages\yahoo_fin\stock_info.py", line 961, in get_quote_data

Click on that link and it should take you the library package and you can do what Dan G mentioned above by changing the V7 in the link to V6 as shown below.

site = "https://query1.finance.yahoo.com/v6/finance/quote?symbols=" + ticker

huangapple
  • 本文由 发表于 2023年5月15日 04:28:13
  • 转载请务必保留本文链接:https://go.coder-hub.com/76249540.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定