url = 'http://www.stackoverflow.com'

def page_to_file(page):
    with open('output', 'w') as f:
        f.write(page.mainFrame().toHtml())
f.close()
app = QApplication()
page = QWebPage()
signal.signal(signal.SIGINT, signal.SIG_DFL)
page.connect(page, SIGNAL('loadFinished(bool)'), page_to_file)
page.mainFrame().load(QUrl(url))
sys.exit(app.exec_())
How to use python urlopen scraping after a page finish loading all searching result?