Android HTML中的元素使用JSON解析两次
我的网站包含149个标签Android HTML中的元素使用JSON解析两次,android,html,json,Android,Html,Json,我的网站包含149个标签 <!-- Begin Module Image --> <div class="module-img"> <a href="http://prodigy.co.id/news/events/youtube-viewer-event/" > <img src="http://prodigy.co.id/wp-content/uploads/Prodi
<!-- Begin Module Image -->
<div class="module-img">
<a href="http://prodigy.co.id/news/events/youtube-viewer-event/" >
<img src="http://prodigy.co.id/wp-content/uploads/Prodigy_Sticky_YoutubeViewer.png" width="280" height="150" alt="Youtube Viewer Event!" />
<span></span>
</a>
<div class="lightboxLink">
<a class="popLink boxLink" href="http://prodigy.co.id/wp-content/uploads/Prodigy_Sticky_YoutubeViewer.png" data-rel="prettyPhoto[Youtube Viewer Event!]" title="Youtube Viewer Event!"></a>
</div>
<div class="thumbLink">
<a class="popLink" href="http://prodigy.co.id/news/events/youtube-viewer-event/" title="Full Post"></a>
</div>
</div>
<!-- End Module Image -->
我希望我的href是http://prodigy.co.id/news/events/youtube-viewer-event/
,且src应为http://prodigy.co.id/wp-content/uploads/Prodigy_Sticky_YoutubeViewer.png
共149次。在这一点上,我完全搞不清楚元素divs
的大小是444,而不是应该的149
请原谅我的懒惰,但我对JSON是新手,我已经在谷歌上搜索了几个小时寻找答案。我从未使用过这个jsoup API,但看看您使用的选择器,似乎您正在查询从
派生的所有标记。请注意,关于选择器和组合器有3个。您确定大小为444吗?如果是447,那就有意义了
选择器对HTML代码中的所有三个链接都有效。空格表示中间可以有任意数量的元素。如果只想选择直接子节点,则必须在以下两者之间使用“>”:
Elements divs = document.select("div[class=module-img] > a[href]");
附言:你可以用
.classname
而不是
div[class=classname]
.classname
div[class=classname]