http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack
using System; using System.Collections.Generic; using System.Linq; using HtmlAgilityPack; namespace ConsoleApplication { class Program { static void Main(string[] args) { string url = "http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack"; var Webget = new HtmlWeb(); var doc = Webget.Load(url); foreach (HtmlNode node in doc.DocumentNode.SelectNodes("//li")) { Console.WriteLine(node.ChildNodes[0].InnerHtml); } } } }
実行結果
Stack Overflow Server Fault Super User Web Applications Ask Ubuntu Webmasters Game Development TeX - LaTeX Programmers Unix & Linux Ask Different (Apple) WordPress Development Geographic Information Systems Electrical Engineering Android Enthusiasts Information Security Database Administrators Drupal Answers SharePoint User Experience Mathematica Salesforce ExpressionEngine® Answers Photography Science Fiction & Fantasy Graphic Design Movies & TV Seasoned Advice (cooking) Home Improvement Personal Finance & Money Academia English Language & Usage Skeptics Mi Yodeya (Judaism) Travel Christianity Arqade (gaming) Bicycles Role-playing Games Mathematics Cross Validated (stats) Theoretical Computer Science Physics MathOverflow Chemistry Biology Stack Apps Meta Stack Exchange Area 51 Stack Overflow Careers