Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- from PyQt4.QtGui import QApplication
- from PyQt4.QtWebKit import QWebPage
- from PyQt4.QtCore import QUrl
- class SimpleWebkit(QWebPage):
- def __init__(self, url):
- self.app = QApplication(sys.argv)
- QWebPage.__init__(self)
- self.loadFinished.connect(self.save)
- self.mainFrame().load(QUrl(url))
- self.app.exec_()
- def save(self):
- self.html = self.mainFrame().toHtml()
- self.app.quit()
- def get_html(url):
- s = SimpleWebkit(url)
- return str(s.html) # QString to string !
- #############################################################################
- if __name__ == "__main__":
- url = 'http://simile.mit.edu/crowbar/test.html'
- print get_html(url) # OK
- print '=========='
- print get_html(url) # never called :(
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement