擅长:python、mysql、java
<p><strong>Java:</strong>
有了这个Chrome和Firefox,就可以加载图像。语法不同,但参数上的字符串相同。</p>
<pre><code> chromeOptions = new ChromeOptions();
HashMap<String, Object> images = new HashMap<String, Object>();
images.put("images", 2);
HashMap<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values", images);
chromeOptions.setExperimentalOption("prefs", prefs);
driver=new ChromeDriver(chromeOptions);
firefoxOpt = new FirefoxOptions();
FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("permissions.default.image", 2);
firefoxOpt.setProfile(profile);
</code></pre>