Why do I get 403 message when trying to download stock historical data from yahoo from 3/5/21? Before works
16 ビュー (過去 30 日間)
古いコメントを表示
Hi,
I always use [temp, status] = urlread(url) to get data from yahoo.
For example here is what I used.
t1 = strcat('https://query1.finance.yahoo.com/v7/finance/chart/AAPL?range=3y&interval=1d&indicators=quote&includeTimestamps=true');
[temp, status] = urlread(t1)
Last Friday I tried to use this same, but all return w/ 0.
I tried to use webread as Matlab recommended, but got the following error message, can you help here? Thanks,
t1 = strcat('https://query1.finance.yahoo.com/v7/finance/chart/AAPL?range=3y&interval=1d&indicators=quote&includeTimestamps=true');
data = webread(t1)
Error message:
Error using readContentFromWebService (line 46)
The server returned the status 403 with message "Forbidden" in response to the request to URL
https://query1.finance.yahoo.com/v7/finance/chart/AAPL?range=3y&interval=1d&indicators=quote&includeTimestamps=true.
Error in webread (line 125)
[varargout{1:nargout}] = readContentFromWebService(connection, options);
How should I use?
2 件のコメント
Michael
2021 年 3 月 14 日
Intereting ... I am getting the same error message from code that used to work fine a couple of months ago. Did something change on Yahoo side?
Anthony John
2021 年 3 月 29 日
Same for me. Have either of you found a solution? Yahoo's URL appears unchanged.
回答 (1 件)
Ralph N
2021 年 6 月 16 日
Two things changed: (1) they updated the URL (2) they limit particular user agents (Matlab is explicitly rejected)
The URL as of 6/16/2021 is:
symbolString = 'TGT'; % look up Target prices as an example
urlBase = 'https://query1.finance.yahoo.com/v7/finance/download/'; % base as of 6/16/2021
url = [urlBase,symbolString];
Then we explicitly set the user agent:
options = weboptions('UserAgent',''); % as of 6/16/2021 it is enough to submit a blank user agent
1 件のコメント
James morgenstern
2021 年 8 月 16 日
Ralph N -- I could kiss you! I have struggled with this one for months ... I read that Yahoo changed their interface to prevent, among other things my trying to read some finance info tables. This solved the problem: Many thanks.
参考
カテゴリ
Help Center および File Exchange で Web Services についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!