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