我正在使用无图形用户界面的浏览器htmlunit来检索网页的网页内容,代码在除"http://www.xyzzzzzzz.com.sg/“之外的其他网站上都工作得很好。有人能解释为什么会这样吗?我已经在CHROME,FIREFOX和IE这三种浏览器上都使用了HtmlUnit webdriver作为BrowserVersion,什么都不能用。
public class Test{
public static void main(String[] args) throws Exception {
String url = "http://www.xyzzzzzzz.com.sg/";
WebClient webClient = new WebClient(BrowserVersion.CHROME);
webClient.getOptions().setCssEnabled(false);
webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
webClient.getOptions().setThrowExceptionOnScriptError(false);
webClient.getCookieManager().setCookiesEnabled(true);
webClient.getOptions().setUseInsecureSSL(true);
HtmlPage currentPage = (HtmlPage) webClient.getPage(url);
String content = currentPage.asXml();
webClient.waitForBackgroundJavaScript(20000);
System.out.println(content); // NOT SHOWING PROPER CONTECT
}
}发布于 2014-01-07 02:32:41
请你描述一下你没有显示正确的CONTECT.Because是什么意思,我不认为代码中有什么错误。有时JS会在HtmlUnit执行时出现问题,所以也可以通过停止它来检查。
https://stackoverflow.com/questions/20942010
复制相似问题