python硒清除缓存和cookie [英] python selenium clearing cache and cookies

查看:169
本文介绍了python硒清除缓存和cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试清除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

webdriver:geckodriver

webdriver: geckodriver

浏览器平台:Firefox

browser platform: Firefox

推荐答案

对于cookie使用'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硒清除缓存和cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆