类似于JSoup的Net版HTML解析器:NSoup

jopen 11年前

NSoup是 jsoup (http://jsoup.org) HTML 解析器的一个.NET移植。

特性:

  • jQuery 风格的 CSS 选择器,用于从HTML页面查找和抽取数据
  • 清理不信任的源的 HTML 内容 
  • 操作 HTML 文档.

示例代码:

NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(HtmlString);    NSoup.Nodes.Document doc = NSoup.NSoupClient.Connect("http://www.open-open.com/").Get();    ebClient webClient = new WebClient();  String HtmlString=Encoding.GetEncoding("utf-8").GetString(webClient.DownloadData("http://www.open-open.com/"));  NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(HtmlString);    WebRequest webRequest=WebRequest.Create("http://www.open-open.com/");  NSoup.Nodes.Document doc = NSoup.NSoupClient.Parse(webRequest.GetResponse().GetResponseStream(),"utf-8");

项目主页:http://www.open-open.com/lib/view/home/1385364588010