我正在使用gui-less浏览器htmlunits来检索网页的webcontent,并且代码适用于除“http://www.xyzzzzzzz.com.sg/”之外的其他网站。任何人都能解释为什么会这样吗????我已经将HtmlUnit webdriver用于所有三个浏览器CHROME,FIREFOX和IE作为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
}
}
答案 0 :(得分:0)