<th "data-next="/?operator=comcast&from=hbo#guide" >
<a href="/hbo/" title="HBO">
<div>
<img src="//comcast.com/channel_logo/hbo.png?0">
</div>
<span>HBO</span>
</a>
</th>
<th "data-next="/?operator=att&from=fox#guide" >
<a href="/fox/" title="fox">
<div>
<img src="//att.com/channel_logo/fox.png?0">
</div>
<span>FOX</span>
</a>
</th>我想得到data-next中的每个链接,所以我想拥有:/?operator=comcast&from=hbo#guide和/?operator=att&from=fox#guide。但是我对解释有问题,因为我不知道data-next是什么。它不是一个属性,也不是一个元素,所以我不确定我应该在jsoup中使用什么。我会感谢你的帮助
编辑:
整个表头如下所示:
<thead class="channelLogos">
<tr>
<th "data-next="/?operator=comcast&from=hbo#guide"> <a href="/hbo/" title="HBO">
<div>
<img src="//comcast.com/channel_logo/hbo.png?0">
</div> <span>HBO</span> </a> </th>(...) 当我这样做的时候:
Elements elts = doc.select("thead.channelLogos th")
for(Element elt : elts) {
System.out.println(elt.absUrl("data-next"));
}//elts stores th elements but doesn't print anything但像这样:
Elements elts = doc.select("thead.logaStacji th[data-next]");elts为空(size=0)
发布于 2016-03-13 11:20:42
试试这个:
String html = loadHTML(...);
Document doc = Jsoup.parse(html);
Elements elts = doc.select("th[data-next]");
for(Element elt : elts) {
// Get absolute url stored in data-next attribute
System.out.println(elt.absUrl("data-next"));
}https://stackoverflow.com/questions/35964764
复制相似问题