pandas-datareader icon indicating copy to clipboard operation
pandas-datareader copied to clipboard

pandas_datareader._utils.RemoteDataError

Open mrhouzlane opened this issue 3 years ago • 1 comments

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

mrhouzlane avatar Sep 05 '22 17:09 mrhouzlane

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 :)

Victorhpinheiro avatar Sep 20 '22 22:09 Victorhpinheiro