[英]HtmlAgilityPACK showing Error “ The given path's format is not supported” when loading html page from web server
I am using my local Apache Server and its address is 127.0.0.1.我正在使用我的本地 Apache 服务器,它的地址是 127.0.0.1。 and i trying to load html page from this server to C# programme using HTML Agility PACk but its showing
我尝试使用 HTML Agility PACK 将 html 页面从该服务器加载到 C# 程序,但它显示
ERROR: The given path's 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 suggesion i Changed my COde and its working Fine非常感谢@Slaks 在您提出建议后我更改了我的代码并且工作正常
HtmlAgilityPack.HtmlDocument docHtml = new HtmlAgilityPack.HtmlDocument();
HtmlAgilityPack.HtmlWeb docHFile = new HtmlWeb();
docHtml = docHFile.Load("http://127.0.0.1/2.html");
doc.Load
takes a path to a local file on disk. doc.Load
获取磁盘上本地文件的路径。
You should use the HtmlWeb
class:您应该使用
HtmlWeb
class:
HtmlDocument docHtml = new HtmlWeb().Load(url);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.