【发布时间】:2015-10-11 03:58:50
【问题描述】:
对不起我的英语。我使用jsop 库并尝试从表中解析数据。但我没有好的结果。我有这个 html:
<table class="charTable">
<tr>
<th><a href="processor.html">№</a></th>
<th><a href="processor_model.html" >Модель</a></th>
</tr>
<tr valign=top style="background-color:#FFFFFF">
<td><nobr><input type="checkbox" name="887" class="compare_check">1</nobr></td>
<td><nobr><b><a href="./processor_887.html">Intel Core i7-4940MX (Haswell)</a></b></nobr></td><td>3100</td>
</tr>
<tr>.....</tr>
<tr>.....</tr>
<tr>.....</tr>
<tr>.....</tr>
</table >
我需要这个字符串:
Intel Core i7-4940MX (Haswell)
我喜欢这样:
Elements text = doc.select("tbody > tr > td > nobr > b > a");
然后他输出了我
<a href="./processor_887.html">Intel Core i7-4940MX (Haswell)</a>
【问题讨论】:
-
"... > b > a").first().text() 工作?
-
@Tim 是的,谢谢。我确实喜欢这个
doc.select("tbody > tr > td > nobr > b > a").first().toString(),但它只输出一次。我认为我需要获取元素并获取该元素。我会试试的 -
啊,好的。所以通过文本迭代,应该工作。 for (元素 e: text) System.out.println(e.text());
-
np,如果对你有用,请接受答案