Web Scraping by Patrik

Html Agility Pack Sample

Load Html From Web

HtmlWeb.Load method gets an HTML document from an internet resource.

Example

The following example loads an Html from the web.

var html = @"http://html-agility-pack.net/";
HtmlWeb web = new HtmlWeb();
var htmlDoc = web.Load(html);
var node = htmlDoc.DocumentNode.SelectSingleNode("//head/title");
Console.WriteLine("Node Name: " + node.Name + "\n" + node.OuterHtml);

Source: Load from Web Method in Html Agility Pack

For an end-to-end sample see Easily Do Web Scraping In .NET Core 6.0

Comments

Leave a Comment

All fields are required. Your email address will not be published.