获取整个文档innerhtml [英] Get the entire document innerhtml
本文介绍了获取整个文档innerhtml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有办法获取整个页面的innerhtml,包括html,head,body等。
Is there a way to get the innerhtml for the entire page, including html, head, body and so on.
我只能调用 page.getDocument()。getBody()。getInnerHTML()
...没有 page.getDocument()。getInnerHTML()
...应该没有?
I am only able to call page.getDocument().getBody().getInnerHTML()
... there is no page.getDocument().getInnerHTML()
... shouldn't there be ?
推荐答案
Ui4j没有这样的api,但您可以使用以下示例来获取整个页面的innerhtml。
There is no such api for Ui4j but you could use the following example to get innerhtml of the entire page.
import static com.ui4j.api.browser.BrowserFactory.getWebKit;
import com.ui4j.api.browser.Page;
public class Main {
public static void main(String[] args) {
Page page = getWebKit().navigate("https://bing.com");
String html = (String) page.executeScript("document.documentElement.innerHTML");
System.out.println(html);
}
}
这篇关于获取整个文档innerhtml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文