0
我試圖使用HTMLUnit獲取網頁上的JavaScript元素(https://www.coursera.org/courses),並且它僅加載html數據。我如何獲得它顯示在javascript容器中顯示的信息?使用HTMLUnit獲取JavaScript元素
謝謝!
我當前的代碼:
public String DownloadPage(String str){
final WebClient webClient = new WebClient(BrowserVersion.FIREFOX_3_6);
webClient.getOptions().setTimeout(20000);
webClient.getOptions().setJavaScriptEnabled(true);
webClient.getOptions().setThrowExceptionOnScriptError(false);
try{
HtmlPage page = webClient.getPage(str);
XmlPage page2 = webClient.getPage(str);
int n = webClient.waitForBackgroundJavaScript(100000);
System.out.println("Executing " + n + " JavaSript jobs!");
System.out.println("OUTPUT: " + page2);
System.out.println("OUTPUT: " + page.asXml());
webClient.closeAllWindows();
}
catch(IOException e){
JOptionPane.showMessageDialog(null, "error");
}
webClient.closeAllWindows();
return "";
}