python webkit webview remember cookies?

后端 未结 2 1804
孤独总比滥情好
孤独总比滥情好 2020-12-06 08:23

I have written a short python script that opens Google music in web view window. however I can\'t seem to find anything about getting webkit to use cookies so that I don\'t

2条回答
  •  死守一世寂寞
    2020-12-06 08:49

    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.

    This is basically same answer from Matt, just using GIR introspection and feels more pythonish.

    from gi.repository import Soup
    cookiejar = Soup.CookieJarText.new("", False)
    cookiejar.set_accept_policy(Soup.CookieJarAcceptPolicy.ALWAYS)
    session = WebKit.get_default_session()
    session.add_feature(cookiejar)
    

提交回复
热议问题