yfinance icon indicating copy to clipboard operation
yfinance copied to clipboard

.get_news() seems to work intermittently; why?

Open eltirobert opened this issue 2 years ago • 6 comments

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 avatar Nov 04 '23 02:11 eltirobert

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.

eltirobert avatar Nov 08 '23 22:11 eltirobert

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

Lamassucoding avatar Mar 22 '24 17:03 Lamassucoding

Does this happen with version >= 0.2.32?

ValueRaider avatar Mar 22 '24 18:03 ValueRaider

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 avatar Mar 22 '24 19:03 Lamassucoding

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 avatar Mar 23 '24 02:03 Lamassucoding

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

Lamassucoding avatar Mar 25 '24 18:03 Lamassucoding