[英]Java jsoup link selecting
I have the following code: 我有以下代码:
Document doc = Jsoup.connect(mainPage).get();
Elements section = doc.select("#main");
Elements allArtTags = section.select("article");
for (Element artTag : allArtTags ){
Elements atags = artTag.select("a");
}
As you see first I am selecting the #main
and then "article"
, finally for each element getting the link with select("a")
, my question is can this code be optimized in some way so to display again the same links but in more optimized way(or less code) 如您所见,我首先选择
#main
,然后选择"article"
,最后对于每个元素都获得带有select("a")
链接的元素,我的问题是,可以以某种方式优化此代码以便再次显示相同的链接,但是以更优化的方式(或更少的代码)
can this code be optimized in some way so to display again the same links but in more optimized way(or less code)
能否以某种方式优化此代码,以便再次显示相同的链接,但以更优化的方式(或更少的代码)显示
Write the code like below: 编写如下代码:
Document doc = Jsoup.connect(mainPage).get();
for (Element aTag : doc.select("#main article a")){
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.