从Web服务器加载html页面时,HtmlAgilityPACK显示错误"不支持给定路径的格式"

pan*_*dra 6 c# web-services web-applications html-agility-pack

我正在使用我的本地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");


    }
Run Code Online (Sandbox Code Playgroud)

非常感谢@Slaks在你的建议后我改变了我的COED并且工作正常

 HtmlAgilityPack.HtmlDocument docHtml = new HtmlAgilityPack.HtmlDocument();
        HtmlAgilityPack.HtmlWeb docHFile = new HtmlWeb();

        docHtml = docHFile.Load("http://127.0.0.1/2.html");
Run Code Online (Sandbox Code Playgroud)

SLa*_*aks 18

doc.Load 获取磁盘上本地文件的路径.

你应该使用这个HtmlWeb类:

HtmlDocument docHtml = new HtmlWeb().Load(url);
Run Code Online (Sandbox Code Playgroud)