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.
Image Analyst
Image Analyst 2019 年 11 月 3 日
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 ExchangeMATLAB についてさらに検索

製品

リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by