[Interest] FW: QWebview signals with dynamic web pages

Daniele Esposti expo at expobrain.net
Thu Mar 1 23:38:10 CET 2012


You can try to use a custom QNetworkAccessManager class set to your
QWebView to catch the JS requests and parse the result. In theory all
the requests network requests (even the JS one) should go through
there.

On 1 March 2012 19:08, Murphy, Sean M. <sean.murphy at gd-ais.com> wrote:
> Ok, I’ll see if that helps, although I do sort of want my application to
> still display the page.  Basically I want a Qt application that is a single
> purposed web browser with logging capabilities, so when you launch my app,
> it just connects to the sensor, asks you where you want to put the log file,
> and then allows you to watch the temperatures live, and know they are being
> logged as well…
>
>
>
> So if this device is using javascript to update the code, what are the
> actual mechanics to make the QWebView redraw the page, without having to
> reload the HTML?
>
>
>
> Sean
>
>
>
> From: daniele.esposti at gmail.com [mailto:daniele.esposti at gmail.com] On Behalf
> Of Daniele Esposti
> Sent: Thursday, March 01, 2012 1:20 PM
> To: Murphy, Sean M.
> Subject: Re: [Interest] FW: QWebview signals with dynamic web pages
>
>
>
> With Firebug you will be able to see the .js file and what URL Javascript
> calls to update the value.
>
> With this you can query the sensor directly without loading the whole page.
>
> On Mar 1, 2012 5:40 PM, "Murphy, Sean M." <sean.murphy at gd-ais.com> wrote:
>
> Forwarding back to the list
>
>> As far as I can understand from your explanation I think the sensor's
>> values are update by Javascript.
>> Try to see in the page's source if there is a <script> element.
>> Another tip: try Firefox + Firebug to debug the sensors web page and find
>> out how it updates the on-screen values.
>
> Yes, there is definitely javascript involved.  There are  few lines like:
>  <script src="webtemp.js" type="text/javascript"></script>
>
> So unfortunately I can't see the actual javascript code directly in the
> HTML.  I'll see if I can get Firebug up and running, but even if I do, will
> that actually help?  Is there any signal that gets fired off as javascript
> functions get evaluated?
>
> Sean
>
>>> 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.
>>>
>>> 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() finishes.
>>>
>>> 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
> http://lists.qt-project.org/mailman/listinfo/interest
> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest



-- 
Daniele Esposti

My Blog http://www.expobrain.net
LinkedIn http://www.linkedin.com/in/danieleesposti
Twitter http://www.twitter.com/#!/expobrain



More information about the Interest mailing list