如何使用无头硒下载文件?

时间:2019-02-20 08:18:31

标签: python selenium headless selenium-firefoxdriver

我正在使用无头硒下载一些文件。但是当我触发下载按钮时没有任何反应。我使用代码来绕过下载弹出窗口,但是不能

FirefoxProfile profile = new FirefoxProfile();

profile.setPreference("browser.download.folderList",2); //Use for the default download directory the last folder specified for a download
profile.setPreference("browser.download.dir", "/Path/to/directory"); //Set the last directory used for saving a file from the "What should (browser) do with this file?" dialog.
profile.setPreference("browser.helperApps.neverAsk.saveToDisk", "application/pdf"); //list of MIME types to save to disk without asking what to use to open the file

firefoxOptions.setProfile(profile);

0 个答案:

没有答案