Reputation: 2623
I have downloaded the following page using wget and saved it in f.html
Now I want to load this page for parsing using HtmlAgilityPack in C#. Using this code snippet
var webGet = new HtmlWeb();
var document = webGet.Load("f.html");
Second line is throwing this error
A first chance exception of type 'System.UriFormatException' occurred in System.dll
What's the solution ??
Upvotes: 0
Views: 4957
Reputation: 613
Try the following:
var url = "http://www.ebay.com/sch/i.html?_nkw=gruen&_in_kw=1&_ex_kw=sara+quartz+embassy+bob+robert+elephants+adidas&_sacat=See-All-Categories&_okw=gruen&_oexkw=sara+quartz+embassy+bob+robert+elephants+adidas&_adv=1&_udlo=&_udhi=&_LH_Time=1&_ftrt=903&_ftrv=24&_sabdlo=&_sabdhi=&_samilow=&_samihi=&_sadis=200&_fpos=Zip+code&_fsct=&LH_SALE_CURRENCY=0&_sop=12&_dmd=1&_ipg=50";
var document = new HtmlDocument();
document.LoadHtml(new WebClient().DownloadString(url));
If you want to load it from a local file then try:
var file = "f.html";
var document = new HtmlDocument();
document.LoadHtml(File.ReadAllText(file));
Upvotes: 0
Reputation: 48230
I don't have the compiler at hand but I suppose that "f.html"
is not a well formed Uri. It lacks the schema and the domain.
The correct uri should be like "http://the.domain.name/f.html"
.
Upvotes: 2