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

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章