Advertisement
stuppid_bot

Untitled

Jun 6th, 2015
402
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.33 KB | None | 0 0
  1. from PyQt5.QtWidgets import QApplication
  2. from PyQt5.QtWebKitWidgets import QWebView
  3. from PyQt5.QtNetwork import QNetworkAccessManager
  4. from PyQt5.QtCore import QUrl
  5. import logging
  6.  
  7. logger = logging.getLogger()
  8. logging.basicConfig(level=logging.DEBUG)
  9.  
  10.  
  11. class NetworkAccessManager(QNetworkAccessManager):
  12.     def __init__(self, parent=None):
  13.         QNetworkAccessManager.__init__(self, parent)
  14.  
  15.     def createRequest(self, op, req, outgoingData=None):
  16.         cookies = self.cookieJar().cookiesForUrl(req.url())
  17.         for c in cookies:
  18.             # http://doc.qt.io/qt-5/qnetworkcookie.html
  19.             logger.debug(
  20.                 ("domain=%s, expiration=%s, httpOnly=%s, secure=%s, "
  21.                     "sessionCookie=%s, name=%s, path=%s, value=%s"),
  22.                 c.domain(),
  23.                 c.expirationDate(),
  24.                 c.isHttpOnly(),
  25.                 c.isSecure(),
  26.                 c.isSessionCookie(),
  27.                 c.name(),
  28.                 c.path(),
  29.                 c.value()
  30.             )
  31.         return QNetworkAccessManager.createRequest(self, op, req, outgoingData)
  32.  
  33.  
  34. if __name__ == '__main__':
  35.     app = QApplication([])
  36.     webview = QWebView()
  37.     webview.page().setNetworkAccessManager(NetworkAccessManager())
  38.     webview.show()
  39.     webview.load(QUrl("https://vk.com"))
  40.     app.exec_()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement