HtmlAgilityPACK shows "This path format is not supported" error when loading an html page from a web server

I am using my local Apache server and its address is 127.0.0.1. and I'm trying to load an html page from this server into a C # program using HTML Agility PACk but showing

ERROR: This path format is not supported.

HtmlAgilityPack.HtmlDocument docHtml = new HtmlAgilityPack.HtmlDocument(); docHtml.Load(@"htttp://127.0.0.1/2.htm"); // <--- error pointer showing here foreach(HtmlNode link in docHtml.DocumentNode.SelectNodes("//a[@href]")) { link.Attributes.Append("class","personal_info"); } docHtml.Save("testHTML.html"); } 

Thank you very much @Slaks after your suggestion I changed my COde and its work Fine

  HtmlAgilityPack.HtmlDocument docHtml = new HtmlAgilityPack.HtmlDocument(); HtmlAgilityPack.HtmlWeb docHFile = new HtmlWeb(); docHtml = docHFile.Load("http://127.0.0.1/2.html"); 
+6
source share
1 answer

doc.Load takes the path to a local file on disk.

You should use the HtmlWeb class:

 HtmlDocument docHtml = new HtmlWeb().Load(url); 
+18
source

Source: https://habr.com/ru/post/891781/


All Articles