我正在使用 gui-less 浏览器 htmlunits 来检索网页的网页内容,并且该代码在“ 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
}
}