本文整理汇总了Java中com.gargoylesoftware.htmlunit.IncorrectnessListener类的典型用法代码示例。如果您正苦于以下问题:Java IncorrectnessListener类的具体用法?Java IncorrectnessListener怎么用?Java IncorrectnessListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IncorrectnessListener类属于com.gargoylesoftware.htmlunit包,在下文中一共展示了IncorrectnessListener类的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createWebClient
import com.gargoylesoftware.htmlunit.IncorrectnessListener; //导入依赖的package包/类
private static WebClient createWebClient(final String url) {
WebClient webClient = new WebClient(BrowserVersion.CHROME);
// http://stackoverflow.com/a/23482615/2246865 by Neil McGuigan
java.util.logging.Logger.getLogger("com.gargoylesoftware.htmlunit").setLevel(Level.OFF);
webClient.setCssErrorHandler(new SilentCssErrorHandler());
webClient.setIncorrectnessListener(new IncorrectnessListener() {
@Override
public void notify(String arg0, Object arg1) {
}
});
webClient.setCookieManager(cookieManager);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getOptions().setPrintContentOnFailingStatusCode(false);
webClient.getOptions().setUseInsecureSSL(true);
// http://stackoverflow.com/a/14227559/2246865 by Lee
webClient.setWebConnection(new WebConnectionWrapper(webClient) {
@Override
public WebResponse getResponse(final WebRequest request) throws IOException {
if (request.getUrl().toString().contains(getDomainName(url))) {
return super.getResponse(request);
} else {
return new StringWebResponse("", request.getUrl());
}
}
});
return webClient;
}
开发者ID:hurik,项目名称:MangaManagerAndDownloader,代码行数:36,代码来源:HTMLUnitHelper.java
注:本文中的com.gargoylesoftware.htmlunit.IncorrectnessListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论