美好的一天,
我正在使用jsoup从表中提取数据
表格内容
<table class="compare-products-table compare-products">
<thead>
<tr>
<th>
<p>GPSMAP</p>
</th>
<th>7x1</th>
<th>8x0/10x0</th>
<th>4000/5000</th>
<th>6000/7000</th>
<th>7400/7600</th>
<th>8000/8500</th>
</tr>
</thead>
<tbody>
<tr>
<td>Radar Overlay</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>Dual Range</td>
<td></td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>MARPA</td>
<td></td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>True Color</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>Auto Bird Gain</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td></td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>Echo Trails</td>
<td class="checked">•</td>
<td class="checked">•</td>
<td></td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>Pulse Expansion <span class="kicker pri sm">NEW</span></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>Dual Radar Support</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
<tr>
<td>Programmable antenna parking</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td class="checked">•</td>
<td class="checked">•</td>
</tr>
</tbody>
</table>
输出值应该像
7x1 -> Radar Overlay: yes
8x0/10x0 -> Radar Overlay: yes
4000/5000 -> Radar Overlay: yes
6000/7000 -> Radar Overlay: yes
7400/7600 -> Radar Overlay: yes
8000/8500 -> Radar Overlay: yes
7x1 -> Dual Range: no
8x0/10x0 -> Dual Range: no
4000/5000 -> Dual Range: yes
6000/7000 -> Dual Range: yes
7400/7600 -> Dual Range: yes
8000/8500 -> Dual Range: yes
等
示例我已经看到,如果内容具有表格属性,如何获取内容并不太清楚
我得到了什么:
Elements elementsFeatures = docProductsAttr.select("#featureTab"); // Feature
if (!elementsFeatures.isEmpty()) {
Elements selectThead = elementsFeatures.select(".compare-products thead tr th:gt(0)"); // get Table Head skipping 1st element
List<String> collectTableHead = selectThead.stream().map(i -> i.text()).collect(toList()); // collect head text value to List
Elements selectTbodyTr = elementsFeatures.select(".compare-products tbody tr"); // select Body tr to mix it with Head value
}
如果有人向我提供实现此目的所需的代码,将不胜感激。