【发布时间】:2013-11-14 23:25:03
【问题描述】:
我有带有代码的 HTML 页面
<td class="c" nowrap>993</td>
我需要解析这个并得到 993
我试试这个代码
doc.select("td.c.nowrap").text()
但它不起作用。请输入正确的变体
【问题讨论】:
标签: html-parsing jsoup
我有带有代码的 HTML 页面
<td class="c" nowrap>993</td>
我需要解析这个并得到 993
我试试这个代码
doc.select("td.c.nowrap").text()
但它不起作用。请输入正确的变体
【问题讨论】:
标签: html-parsing jsoup
nowrap 是一个属性,所以它应该用方括号括起来(根据documentation):
Element e = doc.select("td.c[nowrap]").first();
String number = e.text(); // will be 993
这将选择具有class="c" 和nowrap 属性的<td> 标记的第一个实例。
【讨论】: