c# - HtmlAgilityPACK showing Error " The given path's format is not supported" when loading html page from web server -
i using local apache server , address 127.0.0.1 . , trying load html page server c# programme using html agility pack showing
error : given path's format 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 @slaks after suggesion changed code , working fine
htmlagilitypack.htmldocument dochtml = new htmlagilitypack.htmldocument(); htmlagilitypack.htmlweb dochfile = new htmlweb(); dochtml = dochfile.load("http://127.0.0.1/2.html");
doc.load
takes path local file on disk.
you should use htmlweb
class:
htmldocument dochtml = new htmlweb().load(url);
Comments
Post a Comment