我正在使用 Browsermob 代理通过 chrome webdriver 捕获加载网页的 HAR 内容。
<dependency>
<groupId>net.lightbody.bmp</groupId>
<artifactId>browsermob-core-littleproxy</artifactId>
<version>2.1.0-beta-3</version>
</dependency>
这是我初始化代理的方式:
ChromeOptions options = new ChromeOptions();
for (String extension : DriverProperties.CHROME_EXTENSIONS.getStringArray()) {
options.addExtensions(new File(extension));
}
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability(CapabilityType.ForSeleniumServer.ENSURING_CLEAN_SESSION, true);
capabilities.setCapability(CapabilityType.SUPPORTS_APPLICATION_CACHE, false);
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
capabilities.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
proxy = new BrowserMobProxyServer();
proxy.start(0);
proxy.setHarCaptureTypes(CaptureType.RESPONSE_CONTENT, CaptureType.RESPONSE_BINARY_CONTENT);
// get the Selenium proxy object
Proxy seleniumProxy = ClientUtil.createSeleniumProxy(proxy);
capabilities.setCapability(CapabilityType.PROXY, seleniumProxy);
proxy.newHar();
ChromeDriver driver = new ChromeDriver(capabilities);
但是当我尝试通过 https 获取 url(例如https://screen.yahoo.com)时,我在网络浏览器中看到“此网页具有重定向循环”。有什么解决办法吗?