-
Notifications
You must be signed in to change notification settings - Fork 203
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Not working for stocks or options since last saturday, Jan 27 2024. Have the latest version. 0.3.2. #45
Comments
Yahoo api has changed and now requires "Crumb".
Full explanation here: scheb/yahoo-finance-api#44 Is there anyone working on that already? |
You need to get a crumb from /getcrumb for which you need a cookie which I’m not sure where it’s coming from. Probably some obfuscated javascript |
Okay, I just started to write an API in C++ and libcurl. The Brave inspection gave me these: Request URL: https://finance.yahoo.com/chart/ZURN.SW Request header: :authority: finance.yahoo.com Response header: Cache-Control: no-store Request URL: https://guce.yahoo.com/consent?brandType=nonEu&gcrumb=d2MLOAk&done=https%3A%2F%2Ffinance.yahoo.com%2Fchart%2FZURN.SW Request header: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8 Response header: Connection: keep-alive Request URL: https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_0a35c6d2-d9e1-4d31-af6e-2fa3b396058c Request header: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8 Response header: Cache-Control: no-cache, no-store, must-revalidate Request URL: https://consent.yahoo.com/v2/collectConsent?sessionId=3_cc-session_0a35c6d2-d9e1-4d31-af6e-2fa3b396058c Request header: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8 Response header: Connection: keep-alive Form Data: csrfToken: d2MLOAk Request URL: https://guce.yahoo.com/copyConsent?sessionId=3_cc-session_0a35c6d2-d9e1-4d31-af6e-2fa3b396058c&lang=hu-HU Request header: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8 Response header: Connection: keep-alive Request URL: https://finance.yahoo.com/chart/ZURN.SW?guccounter=1 Request header: :authority: finance.yahoo.com Response header: Age: 1 Request URL: https://query2.finance.yahoo.com/v1/test/getcrumb Request header: :authority: query2.finance.yahoo.com Response header: Age: 0 Response: Rg/wiUEL7kh <- This is the crumb. At step 4. there is a POST. Basically here you should get a page where you can click on accept when you are trying to open yahoo finance at the first time. If you open a chart this POST will accept the agreement for you and then the process goes on with and other redirect where you get A1 cookie and so on. Edit: Edit 2: The problem was with get crumb is that I just tried to give to much parameters in the header. The only thing you will need is the user-agent ("Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36 Edg/119.0.0.0" <- this works for me, first I use "Chrome/122.0.6261.69" only, but this is not enough for the crumb to get) and the cookies (attached all of them that I got in the process because I collected them into one std::vector). This will give a crumb that could use in the "https://query1.finance.yahoo.com/v7/finance/" request. So the full process was:
The last two is a bit silly for me, but Brave sended this, so I did the same thing.
|
Thanks @bradacsa I’ll give it a go over the weekend, the other option I’m considering is adding a dependency on https://github.com/ranaroussi/yfinance since they seem to have solved it already |
As I see they did the same thing in data.py. |
I've published a new release v0.4.0 that uses https://github.com/ranaroussi/yfinance to handle all the cookie magic and fetch the data. Please let me know if there are still any issues |
Great ! Thanks, Will try in a day or two and will let you know it is working fine.
Suresh
Yahoo Mail: Search, Organize, Conquer
On Sat, Mar 9, 2024 at 2:51 PM, Mike ***@***.***> wrote:
I've published a new release v0.4.0 that uses https://github.com/ranaroussi/yfinance to handle all the cookie magic and fetch the data. Please let me know if there are still any issues
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
0.4.0 Working !! I use it to download stock and options information including greeks to manage my investments.
Had temporarily been using Yahoofin, but like wallstreet. It is a little bit slow in getting first option price requestvs yahoofin, but I can get all the information on options I need.Thanks for fixing.
On Saturday, March 9, 2024 at 03:54:47 PM PST, suresh chittor ***@***.***> wrote:
Great ! Thanks, Will try in a day or two and will let you know it is working fine.
Suresh
Yahoo Mail: Search, Organize, Conquer
On Sat, Mar 9, 2024 at 2:51 PM, Mike ***@***.***> wrote:
I've published a new release v0.4.0 that uses https://github.com/ranaroussi/yfinance to handle all the cookie magic and fetch the data. Please let me know if there are still any issues
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Getting this message
401 Client Error: Unauthorized for url: https://query2.finance.yahoo.com/v7/finance/options/TICKER
Looks like that error happened in past but fixed.
The text was updated successfully, but these errors were encountered: