我想打印网页的用户评论以及他们给出的评分,我尝试了下面的代码
Elements links = doc.select("p.s_desc,span.s_rating_overal");
//Elements links1 = doc.select();
//System.out.println(links.next());
ListIterator iter= links.listIterator();
while(iter.hasNext())
{
//String test= iter.next().text();
System.out.println("\n"+iter.next());
System.out.println(iter.next()+"\n\n");
}
问题是输出与标签一起出现。
<span class="s_rating_overal">5.3</span>
<p class="s_desc">You don't need a load of explanation on why this phone changed
the market and set the standard, though the ties to AT&T and Apple are way
too strong to truly enjoy this device. The screen and style are now a bit
outdated and the lack of customization make you feel like you are a cow in the t
he big heard of i ecosystem. The ui is still probably the best there is bu
t, come on its time for a face lift.</p>
我怎样才能只得到标签之间的文本提前谢谢
如果我使用 iter.next().text();,我得到以下错误
Crawler.java:44: cannot find symbol
symbol : method text()
location: class java.lang.Object
System.out.println("\n"+iter.next().text());
^
Crawler.java:45: cannot find symbol
symbol : method text()
location: class java.lang.Object
System.out.println(iter.next().text()+"\n\n");
^
2 errors