如何提取从HTML文件在C#中的HTML链接? [英] How to extract html links from html file in C#?

查看:155
本文介绍了如何提取从HTML文件在C#中的HTML链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁能帮我解释如何提取的网址/ C#中的HTML文件链接

Can anyone help me by explaining how to extract urls/links from HTML File in C#

推荐答案

的Html敏捷包

HtmlDocument doc = new HtmlDocument(); 
doc.Load("file.htm");  
foreach(HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]")) 
{
    HtmlAttribute att = link.Attributes["href"];
    yourList.Add(att.Value)  
}  
doc.Save("file.htm");

这篇关于如何提取从HTML文件在C#中的HTML链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆