From: adam <sh...@qq...> - 2015-05-22 03:24:05
|
asashour,thanks very much~ i've change my code,but it doesn't work. WebClient webClient = new WebClient(BrowserVersion.CHROME); webClient.getOptions().setCssEnabled(false); webClient.getOptions().setJavaScriptEnabled(true); webClient.setJavaScriptTimeout(99999); webClient.waitForBackgroundJavaScript(99999); webClient.getOptions().setThrowExceptionOnScriptError(false); webClient.setAjaxController(new NicelyResynchronizingAjaxController()); try { HtmlPage productPage = (HtmlPage)webClient.getPage("http://detail.1688.com/offer/1228752603.html"); HtmlElement dealElement = (HtmlElement) productPage.getFirstByXPath("//*[@id=\"mod-detail-otabs\"]/ul/li[2]/a/span"); HtmlElement commentElement = (HtmlElement) productPage.getFirstByXPath("//*[@id=\"commentbody\"]/dl[1]/dd/div[2]"); if(dealElement!=null) { System.out.println(dealElement.asXml()); } if(commentElement!=null) { System.out.println(commentElement.asXml()); } System.out.println(productPage.asText()); } dealElement and commentElement return null; -- View this message in context: http://htmlunit.10904.n7.nabble.com/How-to-handle-lazyload-page-with-htmlunit-tp36142p36150.html Sent from the HtmlUnit - General mailing list archive at Nabble.com. |