簡體   English   中英

c#使用html agility pack不支持URI格式

[英]c# using html agility pack URI formats not supported

我正在嘗試使用HTML敏捷包讓我的程序讀取文件並從中獲取所有圖像srcs。 這是我到目前為止得到的:

 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;
    }

這是我得到的錯誤:System.ArgumentException:不支持URI格式。

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM