Skip to content

Instantly share code, notes, and snippets.

@pinscript
Created February 10, 2012 14:40
Show Gist options
  • Select an option

  • Save pinscript/1789954 to your computer and use it in GitHub Desktop.

Select an option

Save pinscript/1789954 to your computer and use it in GitHub Desktop.
/*
* HtmlAgilityPack
*/
using System;
using System.Net;
using HtmlAgilityPack;
public class Program {
public static void Main(string[] args) {
var client = new WebClient();
var html = client.DownloadString("http://www.dennissangmo.se");
var doc = new HtmlDocument() {
OptionAddDebuggingAttributes = false,
OptionAutoCloseOnEnd = true,
OptionFixNestedTags = true,
OptionReadEncoding = true
};
doc.LoadHtml(html);
var titles = doc.DocumentNode.SelectNodes("//h2/a");
foreach (var title in titles) {
var node = title;
Console.WriteLine("{0}: {1}", node.InnerText, node.Attributes["href"].Value);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment