HTMLAgilityPack loads AJAX content for scraping

I am trying to clear a webpage using HTMLAgilityPack in a C # web project project.

All the solutions I've seen for this use the WebBrowser control. However, from what I can determine, this is only available in WinForms projects.

I am currently invoking the required page through this code:

var getHtmlWeb = new HtmlWeb();
var document = getHtmlWeb.Load(inputUri);
HtmlAgilityPack.HtmlNodeCollection nodes = document.DocumentNode.SelectNodes("//div[@class=\"nav\"]");

An example bit of code that I saw said to use the WebBrowser control:

if (this.webBrowser1.Document.GetElementsByTagName("html")[0] != null)
_htmlAgilityPackDocument.LoadHtml(this.webBrowser1.Document.GetElementsByTagName("html")[0].OuterHtml);

Any suggestions / pointers on how to capture the page after loading AJAX will be appreciated.

+4
source share
1 answer

, HTMLAgilityPack , html. , , AJAX, HTMLAgilityPack.

, - - , Firebug, , AJAX. . .

+2

All Articles