gpt4 book ai didi

python selenium清除缓存和cookie

转载 作者:太空狗 更新时间:2023-10-29 21:18:05 30 4
gpt4 key购买 nike

我正在尝试清除我的 firefox 浏览器中的缓存和 cookie,但我无法让它工作。我已经搜索过了,我只得到了 java 和 C# 的解决方案。如何在 Python 中清除缓存和 cookie?

Selenium 版本:3.6.0

平台:python

python 版本:2.7.8

网络驱动程序:壁虎驱动程序

浏览器平台:Firefox

最佳答案

对于 cookie 使用 'delete_all_cookies()' 函数

driver.delete_all_cookies()

用于缓存创建配置文件

profile = webdriver.FirefoxProfile()
profile.set_preference("browser.cache.disk.enable", False)
profile.set_preference("browser.cache.memory.enable", False)
profile.set_preference("browser.cache.offline.enable", False)
profile.set_preference("network.http.use-cache", False)
driver =webdriver.Firefox(profile)

关于python selenium清除缓存和cookie,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46529761/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com