0
を使用する:https://demo.tutorialzine.com/2009/09/simple-ajax-website-jquery/demo.html#page3私はHtmlUnitを搭載しprerendererを構築しようとしているし、次のURLでそれをテストしようとしたんだHtmlUnitプリレンダリングJavascriptのウェブサイトへ(HTMLスナップショット)
は、ここに私のコードです:
final WebClient webClient = new WebClient(BrowserVersion.BEST_SUPPORTED);
WebClientOptions options = webClient.getOptions();
options.setCssEnabled(true);
webClient.setCssErrorHandler(new SilentCssErrorHandler());
webClient.setAjaxController(new NicelyResynchronizingAjaxController());
// webClient.setAjaxController(new AjaxController(){
// @Override
// public boolean processSynchron(HtmlPage page, WebRequest request, boolean async) {
// return true;
// }
// });
options.setThrowExceptionOnScriptError(false);
options.setThrowExceptionOnFailingStatusCode(false);
options.setRedirectEnabled(false);
options.setAppletEnabled(false);
options.setJavaScriptEnabled(true);
//options.setUseInsecureSSL(true);
options.setTimeout(50000);
webClient.addRequestHeader("Access-Control-Allow-Origin", "*");
HtmlPage page = webClient.getPage(path);
// important! Give the headless browser enough time to execute JavaScript
// The exact time to wait may depend on your application.
webClient.setJavaScriptTimeout(10000);
webClient.waitForBackgroundJavaScript(10000);
//just wait
for (int i = 0; i < 20; i++) {
synchronized (page) {
page.wait(500);
}
}
String xml = page.asXml();
ここでの問題は、出力HTMLにJavascriptで取り込む必要があるコンテンツが含まれていないことです。
ここで間違っていますか?