简体   繁体   中英

c# using html agility pack URI formats not supported

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM