本文整理汇总了Java中net.lightbody.bmp.proxy.ProxyServer.setCaptureContent方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyServer.setCaptureContent方法的具体用法?Java ProxyServer.setCaptureContent怎么用?Java ProxyServer.setCaptureContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net.lightbody.bmp.proxy.ProxyServer
的用法示例。
在下文中一共展示了ProxyServer.setCaptureContent方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProxy
import net.lightbody.bmp.proxy.ProxyServer; //导入方法依赖的package包/类
private Proxy getProxy() {
ProxyServer server = getServer();
server.setCaptureContent(true);
server.setCaptureHeaders(true);
SeleniumHolder.setProxyServer(server);
Proxy proxy = new Proxy();
try {
proxy = server.seleniumProxy();
String localIp = InetAddress.getLocalHost().getHostAddress();
String proxyStr = String.format("%s:%d", localIp, server.getPort());
proxy.setHttpProxy(proxyStr);
proxy.setSslProxy("trustAllSSLCertificates");
proxy.setFtpProxy(proxyStr);
SeleniumHolder.setProxy(proxy);
} catch (UnknownHostException e) {
LOGGER.error("UnknownHostException occurs", e);
}
return proxy;
}
示例2: withWebDriver
import net.lightbody.bmp.proxy.ProxyServer; //导入方法依赖的package包/类
public BrowserThread withWebDriver(final String browser) throws Exception {
for (int i = 0; i < 50; i++) {
final int port = portCounter.getAndIncrement();
try {
proxyServer = new ProxyServer(port);
proxyServer.start();
break;
} catch (final Exception e) {
proxyServer = null;
logger.info("Unable to open port " + port, e);
}
}
if (proxyServer == null) {
throw new RuntimeException("Unable to start proxy server!");
}
final CrawlerInterceptor crawlerInterceptor = new CrawlerInterceptor();
proxyServer.addRequestInterceptor(crawlerInterceptor);
proxyServer.addResponseInterceptor(crawlerInterceptor);
proxyServer.setCaptureContent(true);
final DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setJavascriptEnabled(true);
capabilities.setCapability(PROXY, proxyServer.seleniumProxy());
this.webDriver = getBrowser(browser, capabilities);
this.crawlerInterceptor = crawlerInterceptor;
crawlerInterceptor.setBrowserId(browserCounter.incrementAndGet());
return this;
}
示例3: proxyServer
import net.lightbody.bmp.proxy.ProxyServer; //导入方法依赖的package包/类
/**
* Starts the proxy server
* @param port
* @return
* @throws Exception
*/
public ProxyServer proxyServer(int port) throws Exception{
ProxyServer server = new ProxyServer(port);
server.start();
server.setCaptureHeaders(true);
server.setCaptureContent(true);
this.server=server;
return server;
}
示例4: startProxy
import net.lightbody.bmp.proxy.ProxyServer; //导入方法依赖的package包/类
@BeforeTest
public void startProxy() throws Exception {
server = new ProxyServer(port);
server.start();
server.setCaptureHeaders(true);
server.setCaptureContent(true);
server.setLocalHost(InetAddress.getByName(proxyIp));
server.newHar("test_proxy");
}