Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
可能重复: 正则表达式匹配打开的标签,XHTML 自包含标签除外
我不太擅长正则表达式。所以这是我的问题:我怎样才能获得和之间的所有 <td><a href="链接">?
<td><a href="
">
<td><a href="link">
使用HTML Agility Pack解析 HTML 文件:
使用 DLL 后,您可以使用如下代码获取值:
linkNode.Attributes["href"]
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); doc.LoadHtml(@"<td><a href=""link"">"); var links = doc.DocumentNode.SelectNodes("//a[@href]") .Select(a => a.Attributes["href"].Value) .ToList();