![](/img/trans.png)
[英]downloading file from FTP server: the given path's format is not supported
[英]HtmlAgilityPACK showing Error “ The given path's format is not supported” when loading html page from web server
我正在使用我的本地 Apache 服务器,它的地址是 127.0.0.1。 我尝试使用 HTML Agility PACK 将 html 页面从该服务器加载到 C# 程序,但它显示
错误:不支持给定路径的格式。
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");
}
非常感谢@Slaks 在您提出建议后我更改了我的代码并且工作正常
HtmlAgilityPack.HtmlDocument docHtml = new HtmlAgilityPack.HtmlDocument();
HtmlAgilityPack.HtmlWeb docHFile = new HtmlWeb();
docHtml = docHFile.Load("http://127.0.0.1/2.html");
doc.Load
获取磁盘上本地文件的路径。
您应该使用HtmlWeb
class:
HtmlDocument docHtml = new HtmlWeb().Load(url);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.