【问题标题】:Get the entire document innerhtml获取整个文档innerhtml
【发布时间】:2015-06-17 15:50:30
【问题描述】:

有没有办法获取整个页面的innerhtml,包括html、head、body等。

我只能打电话给page.getDocument().getBody().getInnerHTML() ...没有page.getDocument().getInnerHTML() ...不应该有吗?

【问题讨论】:

    标签: java javafx ui4j


    【解决方案1】:

    Ui4j没有这样的api,但是你可以使用下面的例子来获取整个页面的innerhtml。

    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);
        }
    }
    

    【讨论】:

    • 是的,可以。感谢一个伟大的框架!你做得很好。等我有钱我给你钱!提示:您应该考虑在 github 页面上添加指向此标签的链接,在这里获得适当的反馈要容易得多。 Gitter 很难导航。他们甚至覆盖了 CTRL + F 甚至不搜索当前页面。
    • @Answers 和问题弹出在谷歌上也更容易:)
    猜你喜欢
    • 1970-01-01
    • 2016-04-18
    • 2021-08-17
    • 2022-08-16
    • 1970-01-01
    • 1970-01-01
    • 2010-11-11
    • 2011-02-08
    • 2011-07-08
    相关资源
    最近更新 更多