Error message Forbidden when using webread in Matlab
34 ビュー (過去 30 日間)
古いコメントを表示
I try to download data from this site:
I have ISIN numbers that I want to download data for. Here I will use the example BMG0451H1170.
When I do it manually it looks like I can do this in two steps:
Step 1:
Go to page
Get the code 0RBA.L
Step 2:
Go to page
Get the data
However, I encounter the following problem when I try to use webread:
When I use
url='https://data.fidessa.com/FragPro2/StockSearch?term=BMG0451H1170'
options = weboptions('Timeout', 5000, 'HeaderFields',{'Content-Type' 'application/json'},'UserAgent','');
searchResult=webread(url,options);
I get the following error message:
The server returned the status 403 with message "Forbidden" in response to the request to URL
The only information I’ve found about this suggested that I’d play around with the UserAgent. I did, but without success. I’ve also tried without the json option.
I get the same error message in step 2. I should use a POST request there, which may be part of the problem. However, in the first step a GET request seems to be enough.
I know I should only ask one question, so I would primarily be very grateful if somebody could help me get past the 403 error. If you have additional information on how I should use the POST request in step 2, I would also appreciate that very much.
Thank you for your help.
5 件のコメント
Geoff Hayes
2022 年 7 月 1 日
編集済み: Geoff Hayes
2022 年 7 月 1 日
@Marcus - a 403 error (to me anyway) means that you are not providing the proper (authroization) credentials along with your request. Or perhaps like you said, there are problems with the site.
採用された回答
Marcus
2022 年 7 月 1 日
4 件のコメント
Lily Yan
2024 年 12 月 14 日
Thanks Marcus for the code snippet. I was able to resolve my problem using the session ID fetched from my browser... To answer the question(s) of how to get session ID (also a note for myself), take Chrome or Edge for example, visit the url manually then press Ctrl-Shift-J to open the dev-tool, then Application > Storage > Session storage and inspect the key-value pairs:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1820968/image.png)
For the session in the screenshot the weboption would look like:
options = weboptions('KeyName', 'cwvSessionId', 'KeyValue', 'f2800315-d7xxxxxxxxxx');
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Manage Products についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!