webkit: is it possible to store cookies to file an

2019-05-10 04:59发布

is it possible to store cookies to file when you use webkit and reuse it again next time when I run my application?

2条回答
爱情/是我丢掉的垃圾
2楼-- · 2019-05-10 05:50

For those using WebKit and Gtk, change the first line from:

from gi.repository import Soup

to:

from gi.repository import Gtk, WebKit, Soup

to avoid static and dynamic conflicts.

查看更多
在下西门庆
3楼-- · 2019-05-10 05:52

I know its old question and have been looking for the answer all over the place. Finally came up on my own after some trial and error. Hope this helps others.

from gi.repository import Soup
cookiejar = Soup.CookieJarText.new("<Your cookie path>", False)
cookiejar.set_accept_policy(Soup.CookieJarAcceptPolicy.ALWAYS)
session = WebKit.get_default_session()
session.add_feature(cookiejar)
查看更多
登录 后发表回答