QWebkit + extracting dynamic DOM data



  • Hello!
    I am looking for decision for extracting calendar data from pages like this:
    http://www.dukascopy.com/swiss/russian/marketwatch/calendars/eccalendar/

    There are js-widget + js-applet. And they load data and insert it to the html DOM. So when I try "inspect element" in firefox, I see, that they are loaded as pure html. Are there any functions in PySide to extract all completely finished DOM data?
    Or are there any functions to extract widgets result?
    Provide plz, if possible examples. Or tell some other way to manage issue.



  • This code prints iframe html content
    @
    #include <QApplication>
    #include <QDebug>
    #include <QWebView>
    #include <QWebFrame>
    #include <QWebElement>
    #include <QTimer>
    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    //Create browser
    QWebView w;
    w.show();

    //Load page
    QEventLoop loop;
    QObject::connect(&w,SIGNAL(loadFinished(bool)),&loop,SLOT(quit()));
         w.load(QUrl("http://www.dukascopy.com/swiss/russian/marketwatch/calendars/eccalendar/"));
    loop.exec&#40;&#41;;
    
    //Wait for 5 seconds
    QTimer::singleShot(5000,&loop,SLOT(quit()));
    loop.exec&#40;&#41;;
    
    //Print contnt of frame
    qDebug()<<w.page()->mainFrame()->childFrames().at(0)->documentElement().toOuterXml();
    
    
    
    return a.exec&#40;&#41;;
    

    }
    @



  • Thank you very much! I have been soiled about it for 2 weeks already on StackOverflow and here is simple and perfect answer!



  • You are welcome :)


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.