【问题标题】:Extract div content with XPath in C#在 C# 中使用 XPath 提取 div 内容
【发布时间】:2011-08-19 12:37:24
【问题描述】:

我正在做一个网页抓取并取回 html。我想用 XPath 从 html 中获取所有 div 内容。这是html的sn-p:

<TD style="background-color:Gainsboro;" class="a83c"><DIV style="word-
wrap:break-word;" class="a83">17173,1</DIV></TD>
<TD style="background-color:Gainsboro;" class="a87c"><DIV style="word-
wrap:break-word;" class="a87">14865,0</DIV></TD>

所以我想从这个例子中提取: 17173,1 和 14865,0

请有人告诉我如何使用 XPath 来实现这一点,或者使用 Regex 是否更容易?

谢谢。

【问题讨论】:

  • 如果您还没有看过它,您可能想看看HTML Agility Pack,它可以让您将 HTML 视为 XML。

标签: c# .net html xml xpath


【解决方案1】:

你应该试试Html Agility pack 和它的xpath support

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-04-05
    • 2017-01-15
    • 2020-08-06
    • 1970-01-01
    • 2020-10-28
    • 2021-07-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多