我正在尝试批量下载BlackBoard环境中的许多文件(在世界各地的大学/学校中使用了很多)。我能够检索这些文件只有一个市长问题的链接:
当该文件是..pdf文件时,它将显示在一个新的浏览器选项卡中,而不是下载。例如..xlsx使用click()下载的文件工作得很好。
是否可以更改驱动器设置以更改此行为?又是如何做到的?
编辑
我根据阿里的回答更新了这个问题。它现在包括更多关于实际插件的信息。也许这可以用来识别必须禁用的插件。
Chrome PDF Viewer (2 files)
Name: Chrome PDF Viewer
Version:
Location: chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai/
Type: BROWSER PLUGIN
Disable
MIME types: MIME type Description File extensions
application/pdf .pdf
Name: Chrome PDF Viewer
Description: Portable Document Format
Version:
Location: internal-pdf-viewer
Type: PPAPI (out-of-process)
Disable
MIME types: MIME type Description File extensions
application/x-google-chrome-pdf Portable Document Format
.pdf 发布于 2017-01-27 09:49:29
阿里的回答几乎正常。我只需要将插件的名称封装到一个列表中:
chromeOptions = webdriver.ChromeOptions()
prefs = {"plugins.plugins_disabled" : ["Chrome PDF Viewer"]} # Here should be a list
chromeOptions.add_experimental_option("prefs",prefs)
chromedriver = "path/to/chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)下载现在工作得很好!
发布于 2017-03-21 12:24:50
铬57改变设置..。使用此选项可禁用Chrome查看器:
//To disable PDF viewer plugins with Chrome 57
chromePrefs.put("plugins.always_open_pdf_externally", true);发布于 2017-01-26 17:30:40
您可以将插件设置为禁用为首选项吗?
chromeOptions = webdriver.ChromeOptions()
prefs = {"plugins.plugins_disabled" : "Chrome PDF Viewer"}
chromeOptions.add_experimental_option("prefs",prefs)
chromedriver = "path/to/chromedriver.exe"
driver = webdriver.Chrome(executable_path=chromedriver, chrome_options=chromeOptions)见"setting Chrome preferences w/ Selenium Webdriver in Python“和"How to disable Chrome Plugins in Selenium WebDriver using Java”。
https://stackoverflow.com/questions/41877155
复制相似问题