如何使用Jsoup获取帧?

4

<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>


我正在解析一个网页,但是遇到了问题。
#document是什么意思?
我如何使用Jsoup解析#document下面的<html>


你可以在这里阅读相关内容: http://www.w3schools.com/jsref/dom_obj_document.asp - Offir
1
可能是What does #document mean?的重复问题。 - Sebastian Simon
1个回答

3
如何使用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();

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接