吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 1439|回复: 3
收起左侧

[求助] Python PySide2 QtWebEngineWidgets 怎么设置cookie

[复制链接]
Glenn 发表于 2021-6-9 16:39
PySide2 QtWebEngineWidgets 怎么设置cookie,百度了找不到结果,求懂的大佬指点迷津

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

葫芦炒鸡蛋 发表于 2021-6-9 21:29
233.jpg
这是我以前写过的代码,可能对你有帮助。
 楼主| Glenn 发表于 2021-6-10 09:51
难搞,翻墙也找不到答案,官方文档看了也没有明确哪个命令可以更改cookie,看到过pyqt5设置cookie的,但是在pyside2上不适用
 楼主| Glenn 发表于 2021-6-10 16:16
我已经可以清除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))
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止回复与主题无关非技术内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-6-10 08:59

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表