BillBie

导航

python 使用selenium下载文件时,chrome会提示是否下载多个文件(Download multiple files)

 1.使用python+selenium+chrome 下载多个文件时,则会提示此提示语,不允许的话,则下载的文件不会被保存下来

 

2.则需要在启动chrome 的时候加上部分设置

options = webdriver.ChromeOptions()
# options.add_argument('--headless')#非GUI页面启动浏览器
# options.add_argument('--disable-gpu')
prefs = {'profile.default_content_settings.popups': 0, 'download.default_directory': r'e:\music',"profile.default_content_setting_values.automatic_downloads":1}

options.add_experimental_option('prefs', prefs)
self.driver = webdriver.Chrome(options=options)

参考地址:https://stackoverflow.com/questions/15817328/disable-chrome-download-multiple-files-confirmation

posted on 2019-01-23 19:16  BillBie  阅读(209)  评论(0)    收藏  举报