【发布时间】:2013-11-25 22:52:49
【问题描述】:
我只是想从这个源代码中提取一些文本而发疯:
<tr class="even">
<!-- Title -->
<td class="title riot" title="Summoners, We will be performing Live Maintenance on the 26/11 at 04:00 AM, where we will need to bring the EUW Platform offline. Following up...">
我尝试了很多构造函数的组合,但如果没有任何建议,我真的无法做到这一点...我需要在标题之后的 " 之间捕捉文本...
请注意,有一个类似的类,称为“odd”,与第一个具有相同的语法,就是这样:
<tr class="odd">
<!-- Title -->
<td class="title riot" title="Summoners, welcome to the Service Status forum! Here you can come to see information regarding ongoing issues or events that we are currently working...">
所以,我需要一些能捕捉到这两个类上写的文字的东西……
感谢您的帮助。
编辑:这是我的代码,我在其中连接并捕获一些链接:
Document doc = Jsoup.connect("http://forums.euw.leagueoflegends.com/board/forumdisplay.php?f=10")
.userAgent("Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.172 Safari/537.22")
.timeout(30000).get();
Elements links = doc.select("a[href*=thread]");
for (Element link : links){
if(link.attr("href").contains("board")||link.attr("href").contains("page")||link.text().matches("1")){}
else{
titles.add((String) link.text());
//descriptions.add((String) DEFAULT_FORUM_URL + link.attr("href"));
descriptions.add((String) doc.select("[title*=a]").toString());
}
}
注释行写在 ListView 的每一第二行,即线程的链接上,但我需要在每个类的标签 "td class="title riot" title=" 之间写下简短描述.
自然是这条线
descriptions.add((String) doc.select("[title*=a]").toString());
没用。
【问题讨论】:
标签: java html css parsing jsoup