无法绕过“此类型的文件可能会损害您的计算机”。
使用Java和 Chrome Driver 97+。
尝试:
Map<String, Object> prefs = new HashMap<>();
prefs.put("download.default_directory", "C:\\Users\\Fedor\\Downloads");
prefs.put("download.prompt_for_download", false);
prefs.put("profile.default_content_settings.popups", 0);
prefs.put("safebrowsing.enabled", true);
prefs.put("download.extensions_to_open", "text/x-python");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("start-maximized");
options.addArguments("--safebrowsing-disable-download-protection");
options.addArguments("--safebrowsing-disable-extension-blacklist");
driver = new ChromeDriver(options);
但运气不好...
对于那些认为它是重复的人来说,以下链接对于当前驱动程序版本是***无用的***:
- How to hide the warning "This type of file can harm your computer" while downloading .xml file using Chrome Chromedriver 79 with Selenium Java
- How to disable 'This type of file can harm your computer' pop up
- Unable to download file using ChromeDriver
- ChromeOption '--safebrowsing-disable-download-protection' doesn't disables the download warning in Chrome version 67.x
- How to disable 'This type of file can harm your computer' pop up
- XML file download blocked in selenium chromedriver
- Download .xml file with selenium chrome driver
- How to use chrome webdriver in selenium to download files in python?
1条答案
按热度按时间3lxsmp7m1#
删除参数:
以下参数:
应该能胜任