使用jsoup遍历iframe [英] Traverse Iframe using jsoup
本文介绍了使用jsoup遍历iframe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有这样的html结构。我想得到没有类或id的第二个表。我如何从 iframe
获得第二张表?
I have html structure like this. I want to get the second table that has no class or id. How would I get the second table from the iframe
?
<iframe>
<html>
<body>
<table><table>
<table>
<tr><td></td></tr>
<tr><td></td></tr>
</table>
</body>
</html>
</iframe>
我正在尝试这样
Elements iframe = doc.select("iframe");
for(Element e : iframe) {
System.out.println(e.child(0));
}
任何人都可以帮助我吗?
Can anyone help me?
推荐答案
您想遍历 iframe
元素吗?最好从 iframe获取内容
来源
喜欢
Do you want to traverse the iframe
element? It is better to get the content from iframe
source
like
Element iframe = doc.select("iframe").first();
String iframeSrc = iframe.attr("src");
if(iframeSrc != null) {
iframeContentDoc = Jsoup.connect(iframeSrc).get();
}
您只能这样做。
这篇关于使用jsoup遍历iframe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文