Hi All
I am accessing a website that has a 'Loading screen' once it's all loaded the HTML is readable but every time I use webread it still returns only the 'Loading....' screen HTML.
I've tried going through the browser and setting the weboptions timeout higher but these haven't helped.
would be greatful if someone could point me to something i've missed.
Thanks

 채택된 답변

Image Analyst
Image Analyst 2019년 11월 3일

0 개 추천

Try putting webread in a while loop until it doesn't say that.
maxIterations = 10; % However long you want to wait
count = 1;
while count < maxIterations
pageContents = webread(......)
if ~contains(pageContents, 'Loading...')
% It's not loading anymore so we can quit calling webread().
break;
end
% Wait a little bit
pause(1); % Pause 1 second.
count = count + 1;
end

댓글 수: 2

Edward Heinzelmann
Edward Heinzelmann 2019년 11월 3일
This is such a great answer, I got so far down the route of trying to solve it in one line of code I lost track of the wider picture.
Currently I've been using an active browser and reading the content after a delay but this is nicer.
Thanks so much.
You're welcome. You might want to add some code at the end like
if count >= maxIterations
% Never was able to load the web page. Warn the user.
warningMessage = sprintf('The web page was not returned after waiting %d seconds.', count);
uiwait(warndlg(warningMessage));
return; % Unless you can continue without it.
end

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

제품

릴리스

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by