MCPcopy Index your code
hub / github.com/PyQt5/PyQt / WebView

Class WebView

QWebView/GetCookie.py:20–62  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20class WebView(QWebView):
21
22 def __init__(self, *args, **kwargs):
23 super(WebView, self).__init__(*args, **kwargs)
24 self.cookieView = QTextEdit()
25 self.cookieView.resize(800, 400)
26 self.cookieView.move(400, 400)
27 self.cookieView.setWindowTitle('Cookies')
28 self.cookieView.show()
29 self.loadFinished.connect(self.onLoadFinished)
30
31 def closeEvent(self, event):
32 self.cookieView.close()
33 super(WebView, self).closeEvent(event)
34
35 def bytestostr(self, data):
36 if isinstance(data, str):
37 return data
38 if isinstance(data, QByteArray):
39 data = data.data()
40 if isinstance(data, bytes):
41 data = data.decode(errors='ignore')
42 else:
43 data = str(data)
44 return data
45
46 def onLoadFinished(self):
47 allCookies = self.page().networkAccessManager().cookieJar().allCookies()
48 print("allCookies:", allCookies)
49 for cookie in allCookies:
50 # if cookie.domain() == ".pyqt.site":
51 self.cookieView.append(
52 "domain: " + self.bytestostr(cookie.domain()))
53 self.cookieView.append("path: " + self.bytestostr(cookie.path()))
54 self.cookieView.append("name: " + self.bytestostr(cookie.name()))
55 self.cookieView.append(
56 "value: " + self.bytestostr(cookie.value()))
57 self.cookieView.append('')
58 print("domain:", cookie.domain())
59 print("path:", cookie.path())
60 print("name:", cookie.name())
61 print("value:", cookie.value())
62 print()
63
64
65if __name__ == "__main__":

Callers 1

GetCookie.pyFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected