for (int x = 0; x < 8000; x += 50) {
Document doc = Jsoup.connect("localhost.com/"+x).get();
Elements links = doc.select("a[href]");
for (Element link: links) {
String text = link.text();
System.out.println(text);
}
}
}
}
这将使像这样的输出:的java jsoup除去新线
Adrian Riven
HalfSugar No Ice
Yassuo
Amandadog
P1 Sloosh
反正是有删除空行?所以它会看起来像这样的输出:
Adrian Riven
HalfSugar No Ice
Yassuo
Amandadog
P1 Sloosh
我试过 text.replace( “\ n”, “”); text.replaceAll( “\ r \ n吗?”, “”)
编辑这样的,这并没有为我工作 没有尝试另一种
Elements links = doc.select("a[href]");
for (Element link: links) {
Document docs = Jsoup.parse(String.valueOf(links));
docs.outputSettings().escapeMode(Entities.EscapeMode.xhtml);
String text = link.text()+link.text();
System.out.println(text.replace("Show More", ""));
HTML示例:
</td>
<td class="SummonerName Cell">
<a href="/summoner/userName=Cris" class="Link">Cris</a>
</td>
<td class="TierRank Cell">Challenger</td>
<td class="LP Cell">1,137 LP</td>
<td class="TeamName Cell">
Apex Gaming
</td>
<td class="RatioGraph Cell">
<div class="WinRatioGraph">
<div class="Graph">
尝试使用System.out.print(文本),它在文本中有换行符 – ravthiru
你可以把你的示例html代码? – soorapadman
是的,我可以..添加。 – nooby