Skip to content

Instantly share code, notes, and snippets.

@11philip22
Created January 12, 2021 09:55
Show Gist options
  • Save 11philip22/b717357a0c4f78281ed13e138ad8451a to your computer and use it in GitHub Desktop.
Save 11philip22/b717357a0c4f78281ed13e138ad8451a to your computer and use it in GitHub Desktop.
import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
class Render(QWebPage):
def __init__(self, url):
self.app = QApplication(sys.argv)
QWebPage.__init__(self)
self.loadFinished.connect(self._loadFinished)
self.mainFrame().load(QUrl(url))
self.app.exec_()
def _loadFinished(self, result):
self.frame = self.mainFrame()
self.app.quit()
url = 'http://webscraping.com'
r = Render(url)
html = r.frame.toHtml()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment