c# using html agility pack URI formats not supported

c# html-agility-pack

Question

I am trying to use HTML agility pack to get my program to read in a file and get all the image srcs from it. Heres what I got so far:

 private ArrayList GetImageLinks(String html,String link)
    {
        //link = url of webpage
        //html = a string of the html, just for testing will remove after

        HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument();
        htmlDoc.OptionFixNestedTags = true;
        htmlDoc.Load(link);
        List<String> imgs = (from x in htmlDoc.DocumentNode.Descendants()
                             where x.Name.ToLower() == "img"
                             select x.Attributes["src"].Value).ToList<String>();

        Console.Out.WriteLine("Hey");
        ArrayList imageLinks = new ArrayList(imgs);


        foreach (String element in imageLinks)
        {
            Console.WriteLine(element);

        }

        return imageLinks;
    }

And this is the error im getting: System.ArgumentException: URI formats are not supported.

Popular Answer

HtmlDocument docHtml = new HtmlWeb().Load(url);


Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow