Skip to content

Commit ce4226b

Browse files
committed
fixed #125
1 parent 2efce32 commit ce4226b

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

QWebEngineView/SiteDiffUser.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
43
"""
54
Created on 2019年8月23日
65
@author: Irony
@@ -10,15 +9,17 @@
109
@description: 同个网站不同用户
1110
"""
1211

12+
import os
13+
1314
try:
1415
from PyQt5.QtCore import QUrl
15-
from PyQt5.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \
16-
QWebEngineProfile
16+
from PyQt5.QtWebEngineWidgets import (QWebEnginePage, QWebEngineProfile,
17+
QWebEngineView)
1718
from PyQt5.QtWidgets import QApplication, QTabWidget
1819
except ImportError:
1920
from PySide2.QtCore import QUrl
20-
from PySide2.QtWebEngineWidgets import QWebEngineView, QWebEnginePage, \
21-
QWebEngineProfile
21+
from PySide2.QtWebEngineWidgets import (QWebEnginePage, QWebEngineProfile,
22+
QWebEngineView)
2223
from PySide2.QtWidgets import QApplication, QTabWidget
2324

2425

@@ -30,7 +31,9 @@ def __init__(self, *args, **kwargs):
3031
# 用户1
3132
self.webView1 = QWebEngineView(self)
3233
profile1 = QWebEngineProfile('storage1', self.webView1)
33-
profile1.setPersistentStoragePath('Tmp/Storage1')
34+
# 要设置绝对路径,否则会出现部分问题
35+
# 比如 reCaptcha 不能加载,见 https://github.com/PyQt5/PyQt/issues/125
36+
profile1.setPersistentStoragePath(os.path.abspath('Tmp/Storage1'))
3437
print(profile1.cookieStore())
3538
# 如果要清除cookie
3639
# cookieStore = profile1.cookieStore()
@@ -43,7 +46,7 @@ def __init__(self, *args, **kwargs):
4346
# 用户2
4447
self.webView2 = QWebEngineView(self)
4548
profile2 = QWebEngineProfile('storage2', self.webView2)
46-
profile2.setPersistentStoragePath('Tmp/Storage2')
49+
profile2.setPersistentStoragePath(os.path.abspath('Tmp/Storage2'))
4750
print(profile2.cookieStore())
4851
page2 = QWebEnginePage(profile2, self.webView2)
4952
self.webView2.setPage(page2)

0 commit comments

Comments
 (0)