-
-
Save avaris/2802255 to your computer and use it in GitHub Desktop.
PyQt Network Manager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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