public String getParsedPage() { List<String> alertHandler = new LinkedList<String>(); ; WebClient webClient = new WebClient(BrowserVersion.FIREFOX_24); // CHROME); webClient.setAjaxController(new MyNicelyResynchronizingAjaxController()); webClient.getOptions().setJavaScriptEnabled(true); webClient.getOptions().setTimeout(3500); webClient.getOptions().setThrowExceptionOnScriptError(true); webClient.getOptions().setCssEnabled(true); webClient.getOptions().isRedirectEnabled(); webClient.setAlertHandler( new CollectingAlertHandler(alertHandler)); // 将JavaScript中alert标签产生的数据保存在一个链表中 // webClient.getOptions().setThrowExceptionOnScriptError(false); HtmlPage page = null; JavaScriptEngine engine = new JavaScriptEngine(webClient); webClient.setJavaScriptEngine(engine); try { page = webClient.getPage(data); } catch (FailingHttpStatusCodeException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (MalformedURLException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } if (page != null) { return page.asXml(); } return null; }