Error message Forbidden when using webread in Matlab

조회 수: 30 (최근 30일)
Marcus
Marcus 2022년 6월 30일
댓글: Marcus 2023년 9월 25일
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
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
Marcus 2022년 7월 1일
Thanks! It was the cookie that was missing.

댓글을 달려면 로그인하십시오.

채택된 답변

Marcus
Marcus 2022년 7월 1일
I answer my own question. The only thing missing was a cookie:
options = weboptions('Timeout', 5000, 'ContentType','json',...
'KeyName', 'cookie', 'KeyValue', ['JSESSIONID=', sessionID]);
  댓글 수: 3
Eric Machorro
Eric Machorro 2023년 9월 25일
I have the exact same question/issue.
Marcus
Marcus 2023년 9월 25일
This was some time ago, but I think I got the sessionID by first visiting manually, and then getting the sessionID by inspecting that page. But again, it was some time ago, and I don't quite remember.
It was not a beautiful solution. :-)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by