0
考慮URL中的以下HTML。我需要先對文本「學生1」進行搜索,然後選擇相應的學校,在本例中是「麻省理工學院」。我如何在JSOUP中執行此操作?根據搜索文本遍歷JSOUP中的兄弟節點
<table>
<tbody>
<tr>
<td valign="top">
<div style="border-width:1px;border-color:#cccccc;border-style:solid;">
<table bordercolor="#483D8B">
<tbody>
<tr>
<th colspan="2" bgcolor="#483D8B" height="25"><font face="Verdana" size="2" color="white">MIT School</font></th>
</tr>
<tr>
<td width="120" height="15"><font face="Arial" size="2" color="black"> <b>Student 1</b> </font></td>
</tr>
</tbody>
</table>
到目前爲止,我只能夠成功地搜索文本。
System.out.println("This is :"+Jsoup.parse(url, timeout)
.select("b:containsOwn(Student 1");
我得到的輸出是
<b>This is :Student 1</b>
我不能爲JSOUP在網上找到很多例子。對此有幫助嗎?
你確定這是正確的'HTML'嗎?你的'select'中的''b'標籤是從哪裏來的? – TDG