以下是我添加的功能。我在我的网站上得到了一个谷歌 reCAPTCHA,可以通过添加用户代理来侵入。
但即使在添加用户代理之后,我仍然会收到验证码。有没有其他方法可以添加?
Map<String, String> mobileEmulation = new HashMap<>();
mobileEmulation.put("deviceName", "Pixel 2");
Map<String, Object> chromeOptions = new HashMap<>();
chromeOptions.put("mobileEmulation", mobileEmulation);
chromeOptions.put("args",
Arrays.asList("disable-bundled-ppapi-flash",
"disable-extensions",
"profile-directory=Default",
"disable-plugins-discovery",
"--user-agent=" + userAgent));
ChromeOptions co = new ChromeOptions();
co.addArguments("mobileEmulation="+mobileEmulation);
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY,chromeOptions);
System.setProperty("webdriver.chrome.driver", RunConfig.CHROME_DRIVER_EXE);
driver = new ChromeDriver(capabilities);