How to remove error type has no specific constructors

I am trying to parse a webpage. But it gives an error. Please help me. Thanks.

Here is the code:

static void myMain() { using (var client = new WebClient()) { string data = client.DownloadString("http://www.google.com"); HtmlDocument doc = new HtmlDocument(); doc.LoadHtml(data); var nodes = doc.DocumentNode.SelectNodes("//a[@href]"); foreach (HtmlNode link in nodes) { HtmlAttribute att = link.Attributes["href"]; Console.WriteLine(att.Value); } } } 

It gives an error that The type 'System.Windows.Form.HtmlDocument' has no constructors defined. I turned on HAP.

thanks

+4
source share
1 answer

Change

 HtmlDocument doc = new HtmlDocument(); 

to

 HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument(); 

Since you do not want to work with System.Windows.Form.HtmlDocument

+7
source

All Articles