Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. Extract information from a website (HTML) using Qt ?
Forum Updated to NodeBB v4.3 + New Features

Extract information from a website (HTML) using Qt ?

Scheduled Pinned Locked Moved Qt WebKit
3 Posts 3 Posters 1.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    NPLSOOP
    wrote on last edited by
    #1

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

    this is the HTML sorce :

    @ <body>
    <div>
    <table>
    <tbody>
    <tr>
    <td class="myclass">
    <b>123456789</b>
    </td>
    </tr>
    </tbody>
    </table>
    </div>
    </body>@

    so , i try this :

    @
    void My_Test_Dialog::on_pushButton_clicked()
    {

            QWebView *webview = new QWebView(parentWidget());
    
            webview->load(QUrl("http://www.esesese.com"));
    
            webview->show();
    
             // get HTML element information
            QWebElementCollection colls = webview->page()->mainFrame()->findAllElements("td.myclass b");
    
    
    
             foreach(QWebElement elemento, colls)
            {
                        ui->lineEdit_data->setText(elemento.toInnerXml());
            }
    }
    

    @

    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 file.pro is :

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

    1 Reply Last reply
    0
    • V Offline
      V Offline
      Vincent007
      wrote on last edited by
      #2

      findAllElements should be called after loadFinished is emitted with true.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        guru
        wrote on last edited by
        #3

        use this in your .pro file:

        @ QT += core gui webkit @

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved