[Interest] QWebview signals with dynamic web pages
mandeepsandhu.chd at gmail.com
Fri Mar 2 06:08:28 CET 2012
On Thu, Mar 1, 2012 at 10:41 PM, Murphy, Sean M. <sean.murphy at gd-ais.com> wrote:
> I’m trying to read an 8-channel temperature sensor device that outputs its
> data via a web interface. Viewing the device’s web page via a normal web
> browser, or via QWebView::load(), I can see the temperatures correctly. The
> temperature values are “live” in that they automatically update about once a
> second, without the user having to manually reload/refresh the browser. My
> HTML skills are pretty minimal, so I’m not sure what magic it uses to update
> those parameters, but I don’t see any sort of <meta http-equiv="refresh"
> content="1"> tag.
That might be some AJAX-y magic I guess? :) There might be some JS
code that is sending some request and updating only a particular DOM
Is it possible for you to alter the web pages code? If so, you could
probably use the webkit-bridge concept where the page (via some
modified JS code) calls a Qt slot on each refresh.
Or if thats not possible, how about inspecting the DOM and finding out
the value of the required element? I guess you're already doing that
on page load, but you probably don't have to refresh the page from
outside as the page is doing that itself. If you can find the refresh
time that the page is using, you could use the same refresh freq for
parsing the DOM tree once a page load completes. Would that work?
> What I want to do is parse the HTML that comes back from the device and just
> grab the temperatures so that I can timestamp them and log them to a file.
> So I’ve got code that does the parsing correctly. I’ve connected that code
> up to the QWebView::loadFinished(bool) signal, but that only causes my
> parsing code to get triggered once, only when my initial QWebView::load()
> Is there some sort of signal that I can connect to in the QWeb* hierarchy
> that will get triggered everytime the device’s web page updates itself via
> whatever magic it’s using? I’ve tried QWebView::loadFinished() and
> QWebPage::contentsChanged() / QWebPage::loadFinished() and
> QWebFrame::pageChanged / QWebFrame::loadFinished(), but no of those seem to
> get triggered.
> I know I could just set up a QTimer and explicitly call QWebView::load() on
> my own, but that seems overkill, not to mention it’s going to make the web
> page have to redraw which looks ugly to the user.
> Interest mailing list
> Interest at qt-project.org
More information about the Interest