【问题标题】:How to fetch frames with Jsoup?如何使用 Jsoup 获取帧?
【发布时间】:2016-06-27 17:47:09
【问题描述】:

<html>
    <head></head>
    <frameset cols="180,590,*" border="0">  
        <frame src="test.html" name="main" noresize="" scrolling="no" marginwidth="0" marginheight="0">
        <frame src="http://www.test.com/my.php" name="right" noresize="" scrolling="auto" marginwidth="0" marginheight="0">
            #document    <!-- what is this? -->
                <html>
                    <head>
                        <title>TEST</title>
                    </head>
                    <body></body>
                </html>
        </frame>
    </frameset>
</html>


我正在解析一个网页。但我有一个问题。
#documnet 是什么?
以及如何使用Jsoup 解析#document 下面的&lt;html&gt;

【问题讨论】:

标签: html jsoup


【解决方案1】:

我如何使用 Jsoup 解析下面的#document?

您可以将#document 视为“虚拟”元素。 Jsoup 不会看到它。它也不存在于实际的 HTML 代码中。

您想要的是使用 Jsoup 获取帧。见下文:

Document doc = ...; // HTML page containing the frameset

Document mainFrameDocument = Jsoup.connect(doc.select("frame[name=main]").absUrl("src")).get();

Document rightFrameDocument = Jsoup.connect(doc.select("frame[name=right]").absUrl("src")).get();

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-03-14
    • 2017-02-05
    • 2014-05-09
    • 2017-06-14
    • 2021-02-16
    • 1970-01-01
    • 1970-01-01
    • 2022-01-10
    相关资源
    最近更新 更多