<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
?
我该如何解析 <html>
下面#document
使用 Jsoup
?
最佳答案
And how can I parse below #document using Jsoup?
您可以将#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();
关于html - 如何使用 Jsoup 获取帧?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38037886/