Skip to content

Instantly share code, notes, and snippets.

@avaris
Forked from v/test.py
Created May 27, 2012 05:19
Show Gist options
  • Save avaris/2802255 to your computer and use it in GitHub Desktop.
Save avaris/2802255 to your computer and use it in GitHub Desktop.
PyQt Network Manager
from PyQt4.QtGui import *
from PyQt4.QtCore import *
from PyQt4.QtWebKit import *
from PyQt4.QtNetwork import *
import sys
class Render(QWebPage):
def __init__(self, url):
self.app = QApplication(sys.argv)
QWebPage.__init__(self)
self.loadFinished.connect(self._loadFinished)
u = QUrl(url)
self.networkAccessManager().authenticationRequired.connect(self.authenticate)
self.mainFrame().load(u)
self.app.exec_()
def _loadFinished(self, result):
self.frame = self.mainFrame()
self.app.quit()
def authenticate(self, reply, authenticator):
authenticator.setUser('username')
authenticator.setPassword('password')
r = Render('http://mysite.com')
import pdb; pdb.set_trace()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment