【发布时间】:2018-01-21 15:07:46
【问题描述】:
我正在尝试让 cookie 发挥作用。如果我加载一个 cookie 测试页面,它说 cookie 是启用的,但它不会记住登录。
我在下面发布我的代码,在此先感谢。
context = WebKit2.WebContext.get_default()
sm = context.get_security_manager()
self.cookies = context.get_cookie_manager()
self.manager = WebKit2.UserContentManager()
self.webview =
WebKit2.WebView.new_with_user_content_manager(self.manager)
self.add(self.webview)
self.settings = self.webview.get_settings()
cookiesPath = '/tmp/cookies.txt'
storage = WebKit2.CookiePersistentStorage.TEXT
policy = WebKit2.CookieAcceptPolicy.ALWAYS
self.cookies.set_accept_policy(policy)
self.cookies.set_persistent_storage(cookiesPath, storage)
【问题讨论】:
标签: python webkit gtk pygobject