PDA

View Full Version : QWebView Extract Information



tpf80
14th October 2008, 09:22
I have a QWebView that loads a page that has some javascript which modifies the document on the fly. AKA:


document.getElementByID("displayWindow").innerHTML = "Somegeneratedtext";

Is there a way to for my Qt program to look at the modified page, and capture this changed text in say, a QString, perhaps like QTextCursor?

tpf80
14th October 2008, 11:34
From what it looks like, I could use QWebPage * page () to get the page, then QWebFrame * currentFrame () to get the singular frame that appears.

From there I can use QVariant evaluateJavaScript ( const QString & scriptSource ) to "inject" a script that will check the innerhtml, or i could use toHtml () or toPlainText () and parse out the pieces of the web page that I was interested in.

Does this sound like the right direction to go? or is there an easier way?

jacek
23rd October 2008, 01:00
For now there is no direct access to page's DOM tree, so you have to use JavaScript.