admin管理员组文章数量:1130349
参考资料:https://stackoverflow/questions/40654358/how-to-control-the-download-of-files-with-selenium-python-bindings-in-chrome
https://stackoverflow/questions/40654358/how-to-control-the-download-of-files-with-selenium-python-bindings-in-chrome
https://wwwblogs/xiaoxiao-niao/p/7765627.html 这个是讲解 chrome启动参数的
谷歌浏览器的设置原理,其实和firefox的一样的,但是关于chrome的设置参数,网上的资料好少。根据上面的两个资料,可以基本实现了下载自动保存。
from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
prefs = {'download.default_directory':'d:\\download111111', #设置下载路径,路径不存在会自动创建
'download.prompt_for_download':False, #是否弹窗询问
"download.directory_upgrade": False, #还不清楚这个配置是干嘛的
"safebrowsing.enabled": False #是否提示安全警告
}
chrome_options.add_experimental_option('prefs',prefs)
dr = webdriver.Chrome(chrome_options = chrome_options)
dr.get("http://www.baidu")
参考资料:https://stackoverflow/questions/40654358/how-to-control-the-download-of-files-with-selenium-python-bindings-in-chrome
https://stackoverflow/questions/40654358/how-to-control-the-download-of-files-with-selenium-python-bindings-in-chrome
https://wwwblogs/xiaoxiao-niao/p/7765627.html 这个是讲解 chrome启动参数的
谷歌浏览器的设置原理,其实和firefox的一样的,但是关于chrome的设置参数,网上的资料好少。根据上面的两个资料,可以基本实现了下载自动保存。
from selenium import webdriver
import time
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
prefs = {'download.default_directory':'d:\\download111111', #设置下载路径,路径不存在会自动创建
'download.prompt_for_download':False, #是否弹窗询问
"download.directory_upgrade": False, #还不清楚这个配置是干嘛的
"safebrowsing.enabled": False #是否提示安全警告
}
chrome_options.add_experimental_option('prefs',prefs)
dr = webdriver.Chrome(chrome_options = chrome_options)
dr.get("http://www.baidu")
版权声明:本文标题:selenium 设置谷歌浏览器自动保存文件 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/jiaocheng/1758756629a2783786.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论