java - 用Jsoup解析html的时候,getElementsByTag获取不到Element
迷茫
迷茫 2017-04-18 10:10:28
0
1
665
<tr> 

<td class="whitetext" width="10%">2015020743</td>
<td class="whitetext" width="35%">操作系统教程.5版 / 费翔林,骆斌编著</td>
<td class="whitetext" width="13%">2016-09-01</td>
<td class="whitetext" width="13%"><font color="red">2016-10-02 </font></td>
<td width="6%" align="center" class="whitetext">0</td>
<td class="whitetext" width="15%">自科文献二室[2楼西部]</td>
<td width="13%" align="center" class="whitetext">无</td>
<td width="5%" height="35" class="whitetext">

<p id="2"> 
 <input title="renew" class="btn btn-success" type="button" value="续借" onclick="getInLib('2015020743','5F071A7E','2');" disabled> 
</p> 
<p id="2015020743"></p></td> 

</tr>

html是这个
Document doc = Jsoup.parse(html);
Elements eles = doc.getElementsByTag("td");
获取不到元素
Elements eles = doc.getElementsByClass("whitetext");
也获取不到
请问怎么解决

迷茫
迷茫

业精于勤,荒于嬉;行成于思,毁于随。

reply all(1)
大家讲道理

Because trtd都是table的子标签,你这标签不是标准的html,所以他在parse的时候没有正确的解析.
亲测头尾加上tabletag is enough.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template