我正在使用JSoup选择器从表中获取行。但是有一个问题,因为在网站上td类名被弄乱了,因此我需要清理我的值并将那些元素从列表中排除。如果说我的活动元素包含单词“ dancing”,该如何选择从表格中删除整行?
String url = "https://golf.procon.org/met-values-for-800-activities/";
Document doc = Jsoup.connect(url).get();
Element table = doc.select("table").get(1);
Iterator<Element> activity = table.select("td[class=xl75]").iterator();
Iterator<Element> specification = table.select("td[class=xl72]").iterator();
Iterator<Element> metamount = table.select("td[class=xl73],td[class=xl74]").iterator();
元素看起来像这样:
<td class="xl73" style="border-width: medium 0.5pt 0.5pt; border-style: none solid solid; border-color: windowtext; width: 91pt; height: 11.25pt; background-color: transparent;" width="121" height="15">dancing</td>
我需要排除像这样的元素,可能要排除从此之后到行尾的所有列。 非常感谢您的帮助。