pydata / pandas-datareader

Extract data from a wide range of Internet sources into a pandas DataFrame.
https://pydata.github.io/pandas-datareader/stable/index.html
Other
2.94k stars 681 forks source link

pandas_datareader._utils.RemoteDataError #942

Open mrhouzlane opened 2 years ago

mrhouzlane commented 2 years ago

Code :

import pandas as pd
import pandas_datareader.data as web

FB = web.YahooOptions('FB')

for exp in FB.expiry_dates:
    print(exp.isoformat())

I installed pandas-datareader.

Error :

pandas_datareader._utils.RemoteDataError: Unable to read URL: https://query1.finance.yahoo.com/v7/finance/options/FB

Victorhpinheiro commented 2 years ago

Hello,

I had the same problem. Apparently, the API is refusing requests without headers.

My workaround was to add the headers directly to the object.

Also, the ticket FB is returning blank because it got change to 'META'

FB = web.YahooOptions('META')
FB.headers = {'User-Agent': 'Firefox'}
for exp in FB.expiry_dates:
    print(exp.isoformat())

It would be nice to have a default header for that request IMO.

Hope it helps :)