atreadw1492 / yahoo_fin

Scrape stock price history from new (Spring 2017) Yahoo Finance layout
MIT License
286 stars 125 forks source link

get_live_price() Not working #59

Closed hebawom closed 3 years ago

hebawom commented 3 years ago

This function was working until 7pm GMT. But now it gives me this Traceback:

Screenshot 2021-07-09 at 19 00 11

I'm using the latest package version: 0.8.9.

Is this related to the yahoo site change? This was using 'AAPL'

jaydevshelat commented 3 years ago

+1 Suddenly stopped working in last 12-18 hours.

hebawom commented 3 years ago

Just to confirm - the pending PR does not fix this issue

hebawom commented 3 years ago

Printing out the response to the yahoo request: <Response [403]> Not sure that is fixable - right?

erickmartinez commented 3 years ago

It happened the same to me. I looked at the code in the get_data function. If you add the user-agent to the header:

headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}
result = requests.get(site, params=params, headers=headers)

and pass it to the request, it does work. However, I don't know if yahoo will eventually block these requests.

atreadw1492 commented 3 years ago

Thanks for notifying me of the issue - I'm looking into it, and will try to push a patch (if possible) within the next 24 hours

atreadw1492 commented 3 years ago

Please download the latest version - 0.8.9.1. I just pushed this patch to PyPI to update the headers, per @erickmartinez suggestion. This should hopefully resolve these issues. Thank you all for posting and the suggestions.