-
-
Notifications
You must be signed in to change notification settings - Fork 555
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Start clean instance of webview #531
Comments
Good suggestion. Clean state could be set default. |
API specs Links to implementations Cocoa: https://stackoverflow.com/questions/42994553/creating-a-non-tracking-in-app-web-browser GTK: https://webkitgtk.org/reference/webkit2gtk/unstable/WebKitCookieManager.html QT: https://doc.qt.io/qt-5/qml-qtwebengine-webengineprofile.html CEF: https://magpcss.org/ceforum/apidocs3/projects/(default)/CefRequestContext.html EdgeHTML: ¯\_(ツ)_/¯ |
Can I do this in my python code? but form python? |
This can be implemented, but it might require C# code. WebBrowserInterop.dll acts like a bridge for things that cannot be implemented in Python.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
This would be a great addition to webview |
@Ksengine if you want to help, this issue would be a great choice. |
I can do qt and gtk. |
In my experience, the gtk webview doesn't store cookies [edit: by default]. |
Example: how can you store and apply cookie jar to gtk webkitfrom gi.repository import Gtk, WebKit, 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) |
@obfusk 's PR merged into the |
https://github.com/cztomczak/cefpython/blob/v66.0/examples/snippets/network_cookies.py """
Implement RequestHandler.CanGetCookies and CanSetCookie
to block or allow cookies over network requests.
"""
from cefpython3 import cefpython as cef
def main():
cef.Initialize()
browser = cef.CreateBrowserSync(
url="http://www.html-kit.com/tools/cookietester/",
window_title="Network cookies")
browser.SetClientHandler(RequestHandler())
cef.MessageLoop()
del browser
cef.Shutdown()
class RequestHandler(object):
def __init__(self):
self.getcount = 0
self.setcount = 0
def CanGetCookies(self, frame, request, **_):
# There are multiple iframes on that website, let's log
# cookies only for the main frame.
if frame.IsMain():
self.getcount += 1
print("-- CanGetCookies #"+str(self.getcount))
print("url="+request.GetUrl()[0:80])
print("")
# Return True to allow reading cookies or False to block
return True
def CanSetCookie(self, frame, request, cookie, **_):
# There are multiple iframes on that website, let's log
# cookies only for the main frame.
if frame.IsMain():
self.setcount += 1
print("-- CanSetCookie @"+str(self.setcount))
print("url="+request.GetUrl()[0:80])
print("Name="+cookie.GetName())
print("Value="+cookie.GetValue())
print("")
# Return True to allow setting cookie or False to block
return True
if __name__ == '__main__':
main() |
I have finally implemented this. EdgeChromium, CEF, GTK, QT and Cocoa are supported. PR here #869 Incognito is now
|
Specification
Description
It would be useful to start "clean" instance of pywebview (like incognito mode). Currently, cookies are remembered somewhere in the web engine, so each time I start webview session is not clean, some logins are remembered, etc...
It would be nice to have something like
webview.start(clean=True)
JavaFX WebView starts clean every time (by default)
The text was updated successfully, but these errors were encountered: