我想使用jsoup從下面的HTML代碼中提取以下< td>標籤,其中包含class css-sched-table-title和css-sched-waypoint。但是我無法理解有人可以幫助哪裏出錯?無法在java中使用jsoup從html中提取內容?
Document doc = Jsoup.parse("somelink.html");
Elements row = doc.select(".css-sched-table-title td");
Iterator<Element> iterator = row.listIterator();
while(iterator.hasNext())
{
Element element = iterator.next();
String value = element.text();
System.out.println("value : " + value);
}
。
<tr>
<td ALIGN="CENTER" COLSPAN="16" CLASS="css-sched-table-title"><b>Saturday - </b><b>Afternoon</b></td>
</tr>
<tr VALIGN="BOTTOM">
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">Townline and Southern</TD>
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">Clearbrook and Blueridge</TD>
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">Clearbrook and South Fraser</TD>
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">Ar. Bourquin Exchange</TD>
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">Lv. Bourquin Exchange</TD>
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">Downtown Abbotsford</TD>
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">McMillan and Old Yale</TD>
<TD> </TD>
<TD ALIGN="CENTER" WIDTH="100" CLASS="css-sched-waypoints">Sandy Hill and Old Clayburn</TD>
</tr>
你嘗試 「td.css-SCHED表標題」? – Nishant
嗨Nishant沒有工作 –