You are not logged in.

Dear visitor, welcome to QtForum.org. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Monday, October 17th 2011, 5:28am

[SOLVED] QWebView - How to get DOM HTML

I can get the static HTML using "ui->browser->page()->mainFrame()->toHtml();"
It returns fine the static HTML, but several pages use javascript, therefore a lot of parts are looking like this "Loading..." instead of the actual information.
Is there anyway to get the DOM HTML?

The specific piece of HTML that I'm trying to get right now is below;

Source code

1
2
<tr class="data">
  <td class="desc timer">	<span id="Countdown">Loading...</span>  </td></tr>


And the actual result I'm trying to get programatically would be something like this;

Source code

1
2
<tr class="data">
  <td class="desc timer">	<span id="Countdown">2h 44m 18s</span>  </td></tr>


Thanks,
Luís.

This post has been edited 1 times, last edit by "lhg" (Oct 26th 2011, 5:51pm) with the following reason: Topic SOLVED.


2

Wednesday, October 26th 2011, 5:51pm

Figured it out, it's simple enough.

A simple answer to my original thread would be:

PHP Source code

1
2
QWebElement e ui->browser->page()->mainFrame()->findFirstElement("span#Countdown");
qDebug() << e.toPlainText(); //a qDebug just to check it right now - it returns exactly the "2h 44m 18s" as I've mentioned above


Topic Solved.