首页 > 解决方案 > 如何在没有 id 或类的 html 网页中定位元素的值(在 WPF c# 应用程序中使用)

问题描述

我想在属于无线网络无线电的本地 html 网页中获取 div 元素的值(在代码中:x)。这个 div 没有 id 或 class 或属性。我如何在 c# Windows Presentation Foundation 中做到这一点?(值不固定)。我在过去几天搜索了很多。我知道也许最好的方法是使用 html 敏捷包来定位该特定行或索引页面中的所有 div 并通过它的索引找到这个。这是该 html 页面的一部分:

<td rowspan="1">Link Capacity
  <div class="help">header=[Link Capacity]....</div>
</td>
<td>
  <div>x</div>
</td>

我只需要抓住 x 这是一个数字。此外,class="help" 在页面中被多次使用。“Link Capacity”或“header=[Link Capacity]”在代码中使用一次。也许他们是这个解决方案的关键。

标签: javascriptc#htmlwpfhtml-agility-pack

解决方案


推荐阅读