【问题标题】:Clear cookies in QWebEngineView清除 QWebEngineView 中的 cookie
【发布时间】:2018-08-04 14:40:14
【问题描述】:

如何在 PyQt5 中清除 cookie? 我尝试了以下代码:

QWebEngineCookieStore.deleteAllCookies()

我得到了一个错误:

TypeError: deleteAllCookies(self): first argument of unbound method must have type 'QWebEngineCookieStore'

我添加了大括号:

QWebEngineCookieStore().deleteAllCookies()

但是又报错了:

TypeError: PyQt5.QtWebEngineCore.QWebEngineCookieStore cannot be instantiated or sub-classed

【问题讨论】:

    标签: python python-3.x pyqt pyqt5


    【解决方案1】:

    QWebEngineCookieStore 无法创建,你需要从 QWebEngineProfile 中获取它,如下所示:

    QWebEngineProfile.defaultProfile().cookieStore().deleteAllCookies()
    

    【讨论】:

    • AttributeError: type object 'QWebEngineProfile' has no attribute 'default'
    猜你喜欢
    • 2016-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-23
    • 2017-07-15
    • 2014-01-03
    • 2014-01-26
    相关资源
    最近更新 更多