Issues reading updated HTML page content using MATLAB
5 次查看(过去 30 天)
显示 更早的评论
I am writing the web page HTML into a text file as line by line filename = 'webpagecontents.txt'; urlwrite(URL,filename); C = textread(filename, '%s','delimiter', '\n');
The text I am searching for is then extracted from the 16th line as msgbox(C(16))
Now the user interacts with the web page and the status message changes on the actual web page However, I am unable to retrieve it in the text file. It still shows the same old content.
How do I get the updated status message? I right clicked the web page and viewed its source file after the status updation. No change is observed there also. Any help is appreciated
0 个评论
采纳的回答
Guillaume
2015-8-19
Two things:
1. When matlab requests the page from the server (using urlwrite or any other method), it's never going to see the changes generated by the user, the same way you wouldn't expect another user to see the changes you make locally. The only way for you to pick up the changes would be either to talk to the web browser the user is using (assuming it is possible) or to actually render the page in matlab and have the user interact with the page from matlab (assuming it is possible with the limited gui tools of matlab).
2. If, in the web browser, you can't see the changes to the source of the page when you interact with it this means that the page is manipulated using javascript. This only change the content of the page in memory and on screen. Again, just reading the source won't help you and you either need to ask the web browser or implement your own browser.
Basically, your assumption is wrong. The page source itself is not updated, it's only the in-memory representation that is changed.
5 个评论
Guillaume
2015-8-20
I don't believe that you can get the page modification from the WebBrowser control events themselves, as none of them relate to in-memory page change. The only relevant event would be DocumentComplete which is fired when the page is fully loaded, but I don't believe it would detect subsequent changes.
Alternatively, you could just query at regular intervals the html element that you want to watch, something like:
h.Document.getElementbyId('some ID')
%or
h.Document.getElementbyName('some Name e.g. body')
I've never used the webbrowser control and the MSDN doc is hard to navigate, so I don't think I can help you further.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Adding custom doc 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!