python selenium清除缓存和cookies [英] python selenium clearing cache and cookies
本文介绍了python selenium清除缓存和cookies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试清除我的 Firefox 浏览器中的缓存和 cookie,但我无法让它工作.我已经搜索过了,我只得到了 Java 和 C# 的解决方案.如何清除 Python 中的缓存和 cookie?
I'm trying to clear the cache and cookies in my firefox browser but I can't get it to work. I have searched it up and i'm only getting solutions for java and C#. How do I clear the cache and cookies in Python?
硒版本:3.6.0
平台:python
python 版本:2.7.8
python version: 2.7.8
网络驱动程序:geckodriver
webdriver: geckodriver
浏览器平台:火狐
推荐答案
对于cookies使用'delete_all_cookies()'函数
for cookies use 'delete_all_cookies()' function
driver.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清除缓存和cookies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文