Python PySide2 QtWebEngineWidgets 怎么设置cookie
PySide2 QtWebEngineWidgets 怎么设置cookie,百度了找不到结果,求懂的大佬指点迷津这是我以前写过的代码,可能对你有帮助。 难搞,翻墙也找不到答案,官方文档看了也没有明确哪个命令可以更改cookie,看到过pyqt5设置cookie的,但是在pyside2上不适用 我已经可以清除cookie了,但设置cookie还不知道怎么传参数进去
default_profile = QWebEngineProfile.defaultProfile()
print(default_profile.persistentStoragePath())# 打印cookie地址
default_cookie = default_profile.cookieStore()
default_cookie.deleteAllCookies()# 清除cookie
default_cookie.setCookie(cookies.cookie_ycpt)# 这里我传的是字典型,会报错
错误内容:
Traceback (most recent call last):
File "D:\Program Files\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\pydevd.py", line 1448, in _exec
pydev_imports.execfile(file, globals, locals)# execute the script
File "D:\Program Files\JetBrains\PyCharm 2020.2.3\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "D:/Python projects/测试.py", line 19, in <module>
default_cookie.setCookie(cookies.cookie_ycpt)
TypeError: 'PySide2.QtWebEngineCore.QWebEngineCookieStore.setCookie' called with wrong argument types:
PySide2.QtWebEngineCore.QWebEngineCookieStore.setCookie(dict)
Supported signatures:
PySide2.QtWebEngineCore.QWebEngineCookieStore.setCookie(PySide2.QtNetwork.QNetworkCookie, PySide2.QtCore.QUrl = Default(QUrl))
页:
[1]