[英]Extracting particular table data in JSoup
I have the following HTML Code: 我有以下HTML代码:
<tr>
<td class="legend" data-v1="conceded" data-v2="Average</td>
<td data-v1="29" data-v2="1.45">29</td>
<td data-v1="14" data-v2="1.40">14</td>
<td data-v1="15" data-v2="1.50">15</td>
</tr>
I'm trying to get the numbers '29', '14' and '15' however I don't know what their address is to select them. 我正在尝试获取数字“ 29”,“ 14”和“ 15”,但是我不知道选择它们的地址是什么。 I can get the td with the class name using the below code:
我可以使用以下代码获取带有类名的td:
try {
Document doc = Jsoup.connect(URL).get();
Elements E = doc.select(".team-stats.line-end > tbody > tr > td.legend");
System.out.println(E.text());
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
However, the ones with the numbers don't have a class or ID name. 但是,带数字的人没有班级或ID名称。 How can I point to them to extract these individually.
我如何指向他们分别提取这些内容。
Try this selector: 试试这个选择器:
.team-stats.line-end > tbody > tr > td:not(:first-child)
Or: 要么:
.team-stats.line-end > tbody > tr > td:not(.legend)
If you want to refer to exclude the class explicitly. 如果要引用明确地排除该类。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.