Search code examples
c#asp.netscreen-scrapinghtml-agility-pack

How to scrape xml file using htmlagilitypack


I need to scrape an xml file from http://feeds.feedburner.com/Torrentfreak for its links and description.

I used this code :

    var webGet = new HtmlWeb();
                var document = webGet.Load("http://feeds.feedburner.com/TechCrunch");
    var TechCrunch = from info in document.DocumentNode.SelectNodes("//channel")
                                 from link in info.SelectNodes("//guid[@isPermaLink='false']")
                                 from content in info.SelectNodes("//description")
     select new
                                 {
                                     LinkURL = info.InnerText,
                                     Content = content.InnerText,

                                 };
lvLinks.DataSource = TechCrunch;
            lvLinks.DataBind(); 

I have used this in list view control to show on asp.net page. using

<%# Eval("LinkURL") %>  -  <%# Eval("Text") %> 

But its showing error

Value cannot be null. Parameter name: source

what's the problem ? And is it possible to scrape (fetch) xml nodes data using HtmlAgilityPack ? Please suggest Thanks


Solution

  • Try using RSS library instead of the HtmlAgilityPack:

    Here are some links that might help you: