ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
13.15k stars 2.33k forks source link

.get_news() seems to work intermittently; why? #1735

Open eltirobert opened 11 months ago

eltirobert commented 11 months ago

Describe bug

When I run

msft = yf.Ticker('MSFT') msft.get_news()

or any other symbol, not necessarily 'MSFT', sometimes it works, but the majority of the time I get: json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Why is this? How can I fix it and make it work consistently. It throws my whole script off when even one symbol fails. The same thing happens when calling msft.news. It will work once or twice and then fail many more times until I wait a few hours for it to start working again.

Thanks.

Simple code that reproduces your problem

msft = yf.Ticker('MSFT') msft.get_news()

Debug log

json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Bad data proof

No response

yfinance version

0.2.31

Python version

latest

Operating system

macOS

eltirobert commented 10 months ago

Sometimes I have had success passing a proxy to .get_news(proxy = ), but now even that method is not working as it is not accepting any of my proxies. Can someone suggest what can be done? Or maybe in a future version proxies can be fixed, possibly by not using the requests module but rather urllib.

Lamassucoding commented 6 months ago

I'm having same exact issue, any update? any work around? it is intermittent.

ValueRaider commented 6 months ago

Does this happen with version >= 0.2.32?

Lamassucoding commented 6 months ago

I think so, I used to use old version, it stopped working few months back. I just upgraded to the new version and still not working. BTW it is intermitting. thx

Lamassucoding commented 6 months ago

I think I know the issue. when it start failing, I can see from my packet capture (on wireshark) requests are not leaving my PC. But if i run the same code from another python interpreter (another window or Visual studio), start working and i see packets on my packet capture. i think when it hit bad request it get cashed somewhere so when you do same request for same ticker nothing will leave my pc not even one packet. i hope that can point you in the right direction. thx

Lamassucoding commented 6 months ago

not sure if someone looking into this or not. today it (get_news() ) is constantly failing