如何使用Jsoup从链接中提取href?

我想得到这个链接:

index.php?limitstart=0&picno=0&gallery_key=92 index.php?limitstart=0&picno=1&gallery_key=92 index.php?limitstart=0&picno=2&gallery_key=92 

从这个使用Jsoup的html:

      

有任何想法吗? 谢谢

您需要知道公共容器元素的id ,以便您可以在单个CSS选择中获取它们。 根据消息来源,它是

所以,这应该做:

 Elements links = document.select("#redx_gallery_thumb_list a"); for (Element link : links) { String href = link.attr("href"); // Or if you want to have absolute URL instead, so that you can leech them. String absUrl = link.absUrl("href"); // ... }