ruby-on-railsrssfeedjira

Rails: How can I parse an RSS file with Feedjira


I'm trying to parse an RSS file. It throws a 404 response when I do:

Feedjira::Feed.fetch_and_parse url

So I thought trying:

Feedjira::Parser::RSS.parse url

But that returns 0 entries

This is exactly what I'm trying:

<% Feedjira::Parser::RSS.parse("my url here").entries.each do |e| %>

    <%= "#{e.title}" %><br />

<% end %>

The rss file is being parse with no problem with php in another web. This is the structure:

    <rss xmlns:atom="http://www.w3.org/2005/Atom" xmlns:media="http://search.yahoo.com/mrss/" version="2.0">
        <channel>
            <title>Title here</title>
            ... etc ...
            <item>
                <title>Title here</title>
                 ... etc ...
            </item>
            <item> ... etc ... </item>
        </channel>
    </rss>

Solution

  • It's weird that Feedjira::Feed.fetch_and_parse url wasn't working for you. It's working perfectly fine for me.

    Here's how I did it. I'm using Railscasts RSS feed for example purpose:

    url = "http://railscasts.com/subscriptions/rZNfSBu1hH7hOwV1mjqyLw/episodes.rss"
    feed = Feedjira::Feed.fetch_and_parse url
    
    feed.entries.each do |entry|
      puts entry.title
    end