Important: Please read the Qt Code of Conduct -

Extract information from a website (HTML) using Qt ?

  • I'd like extract the "information" in the "b" tag => 123456789

    this is the HTML sorce :

    @ <body>
    <td class="myclass">

    so , i try this :

    void My_Test_Dialog::on_pushButton_clicked()

            QWebView *webview = new QWebView(parentWidget());
             // get HTML element information
            QWebElementCollection colls = webview->page()->mainFrame()->findAllElements("td.myclass b");
             foreach(QWebElement elemento, colls)


    i have a form with a Button("call update") and a LineEdit, so if i click on the "update" button , automatically the LineEdit should set the Text "123456789". but my code doesn't work .. the Text of the LineEdit remains Emply.

    I include this :

    @#include <QtWebKit>
    #include <QtWebKitWidgets/QWebFrame>
    #include <QWebView>@

    QT is :

    @QT += core gui
    QT += network
    QT += webkit
    QT += webkitwidgets@

  • findAllElements should be called after loadFinished is emitted with true.

  • use this in your .pro file:

    @ QT += core gui webkit @

Log in to reply