Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from PyQt5.QtWidgets import QApplication
- from PyQt5.QtWebKitWidgets import QWebView
- from PyQt5.QtNetwork import QNetworkAccessManager
- from PyQt5.QtCore import QUrl
- import logging
- logger = logging.getLogger()
- logging.basicConfig(level=logging.DEBUG)
- class NetworkAccessManager(QNetworkAccessManager):
- def __init__(self, parent=None):
- QNetworkAccessManager.__init__(self, parent)
- def createRequest(self, op, req, outgoingData=None):
- cookies = self.cookieJar().cookiesForUrl(req.url())
- for c in cookies:
- # http://doc.qt.io/qt-5/qnetworkcookie.html
- logger.debug(
- ("domain=%s, expiration=%s, httpOnly=%s, secure=%s, "
- "sessionCookie=%s, name=%s, path=%s, value=%s"),
- c.domain(),
- c.expirationDate(),
- c.isHttpOnly(),
- c.isSecure(),
- c.isSessionCookie(),
- c.name(),
- c.path(),
- c.value()
- )
- return QNetworkAccessManager.createRequest(self, op, req, outgoingData)
- if __name__ == '__main__':
- app = QApplication([])
- webview = QWebView()
- webview.page().setNetworkAccessManager(NetworkAccessManager())
- webview.show()
- webview.load(QUrl("https://vk.com"))
- app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement