PySide. Extracting DOM HTML. AccessNetworkmanager
Question: I need to extract all calendar data from page like
"<http://www.dukascopy.com/swiss/english/marketwatch/calendars/eccalendar/>".
Firstly - to extract all html with inner dom. Using eclipse and Python 3.3,
win7. Searched here answers, and coded smth based on them. Looks like:

    
    
    from PySide import QtGui, QtDeclarative
    from PySide.QtGui import QApplication, QDesktopServices, QImage, QPainter
    from PySide.QtCore import QByteArray, QUrl, QTimer, QEventLoop, QIODevice, QObject
    from PySide.QtWebKit import QWebFrame, QWebView, QWebPage, QWebSettings
    from PySide.QtNetwork import QNetworkAccessManager, QNetworkProxy, QNetworkRequest, QNetworkReply, QNetworkDiskCache
    #!/usr/bin/env python
    """
    app = QApplication(sys.argv)
    web = QWebView()
    web.load(QUrl("http://www.dukascopy.com/swiss/english/marketwatch/calendars/eccalendar/"))
    web.show()
    sys.exit(app.exec_())
    """
    app = QApplication(sys.argv)
    w = QWebView()
    request = QNetworkRequest(QUrl("http://www.dukascopy.com/swiss/english/marketwatch/calendars/eccalendar/"))
    reply = w.page().networkAccessManager().get(request)
    print(reply)
    byte_array = reply.readAll()
    plist = reply.rawHeaderList()
    print(plist)
    print(byte_array)
    

When loading page to QWebView() it works fine (commented code), but I couldn't
find how to extract all html from QWebView(). So i tried via "request" -
decommented code. And nothing prints.


Answer: Try with signals:

    
    
    def print_content():
         print web.page().mainFrame().toHtml() # or toPlainText()
         # or
         # print web.page().currentFrame().toHtml() # or toPlainText()
    

and

    
    
    web.page().mainFrame().loadFinished.connect(print_content)
    # or web.loadFinished.connect(print_content)
    web.load(QUrl("http://www.dukascopy.com/swiss/english/marketwatch/calendars/eccalendar/"))
    web.show()
    

`print_content` should be called then loadFinished signal arrives

