Skip to content

Instantly share code, notes, and snippets.

@v
Created May 27, 2012 05:10
Show Gist options
  • Save v/2802245 to your computer and use it in GitHub Desktop.
Save v/2802245 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)
authenticator = QAuthenticator()
authenticator.setUser('username')
authenticator.setPassword('password')
self.manager = QNetworkAccessManager(self)
#I guess I'm just confused how to use this manager with the rest of my code.
self.manager.authenticationRequired.emit(<something>, authenticator)
self.mainFrame().load(u)
self.app.exec_()
def _loadFinished(self, result):
self.frame = self.mainFrame()
self.app.quit()
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