Web ページのユーザー レビューと、それらによって与えられた評価を印刷したかったので、以下のコードを試しました。
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