yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

URLs produced by get_sec_filings() call for authtentication

Open amgsharma opened this issue 1 year ago • 2 comments

Describe bug

tech_ticker.get_sec_filings()

404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary/%5EYH311?modules=secFilings&corsDomain=finance.yahoo.com&formatted=false&symbol=%5EYH311&crumb=jjGzRrRM4iK

The response from the URL generated by the call is :

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

Simple code that reproduces your problem

msft = yf.Ticker('MSFT')
tech = yf.Sector(msft.info.get('sectorKey'))


# Sector and Industry to Ticker
tech_ticker = tech.ticker

tech_ticker.get_sec_filings()

Debug log

In [37]: yf.enable_debug_mode()

In [42]: tech_ticker.get_sec_filings() In [43]: tech_ticker.get_major_holders() DEBUG get_raw_json(): https://query2.finance.yahoo.com/v10/finance/quoteSummary//^YH311 DEBUG Entering get() DEBUG Entering _make_request() DEBUG url=https://query2.finance.yahoo.com/v10/finance/quoteSummary//^YH311 DEBUG params={'modules': 'institutionOwnership,fundOwnership,majorDirectHolders,majorHoldersBreakdown,insiderTransactions,insiderHolders,netSharePurchaseActivity', 'corsDomain': 'finance.yahoo.com', 'formatted': 'false'} DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'basic' DEBUG Entering _get_cookie_and_crumb_basic() DEBUG reusing cookie DEBUG reusing crumb DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=404 DEBUG toggling cookie strategy basic -> csrf DEBUG Entering _get_cookie_and_crumb() DEBUG cookie_mode = 'csrf' DEBUG Entering _get_crumb_csrf() DEBUG Failed to find "csrfToken" in response DEBUG Exiting _get_crumb_csrf() DEBUG toggling cookie strategy csrf -> basic DEBUG Entering _get_cookie_and_crumb_basic() DEBUG loaded persistent cookie DEBUG reusing cookie DEBUG crumb = 'jjGzRrRM4iK' DEBUG Exiting _get_cookie_and_crumb_basic() DEBUG Exiting _get_cookie_and_crumb() DEBUG response code=404 DEBUG Exiting _make_request() DEBUG Exiting get() ERROR 404 Client Error: Not Found for url: https://query2.finance.yahoo.com/v10/finance/quoteSummary//%5EYH311?modules=institutionOwnership%2CfundOwnership%2CmajorDirectHolders%2CmajorHoldersBreakdown%2CinsiderTransactions%2CinsiderHolders%2CnetSharePurchaseActivity&corsDomain=finance.yahoo.com&formatted=false&crumb=jjGzRrRM4iK

Bad data proof

No response

yfinance version

0.2.51

Python version

3.11.5

Operating system

Pop OS

amgsharma avatar Jan 13 '25 19:01 amgsharma

...
DEBUG Entering _get_cookie_and_crumb()
DEBUG cookie_mode = 'basic'
DEBUG Entering _get_cookie_and_crumb_basic()
DEBUG reusing cookie
DEBUG reusing crumb
...

The very first time yfinance needs a crumb since starting, it should be fetching not reusing. Was this a brand new Python session? Are you running in Jupyter?

ValueRaider avatar Jan 13 '25 20:01 ValueRaider

This has nothing to do with crumbs.

A sector ticker cannot have SEC Filings...

dhruvan2006 avatar Jan 16 '25 11:01 dhruvan2006