【发布时间】: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。