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

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

python 使用selenium下载文件时,chrome会提示是否下载多个文件(Download multiple files)_第1张图片

 

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

python 使用selenium下载文件时,chrome会提示是否下载多个文件(Download multiple files)_第2张图片

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

你可能感兴趣的:(Python,selenium)