29

I'm looking for something that will let me parse Atom and RSS in Ruby and Rails. I've looked at the standard RSS library, but is there one library that will auto-detect whatever type of feed it is and parse it for me?

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112
aronchick
  • 6,786
  • 9
  • 48
  • 75

7 Answers7

31

Feedzirra is one of the better options: http://www.pauldix.net/2009/02/feedzirra-a-ruby-feed-library-built-for-speed.html

Of course, I'm biased since I wrote it. :)

Paul Dix
  • 1,967
  • 16
  • 8
  • I agree. Feedzirra is the best. Really fast. Thanks Paul Dix for this amazing library. – Shripad Krishna Apr 18 '10 at 10:54
  • 4
    Unfortunately, as it is, its active support dependency is broken on its latest version (on rails 2.3.8, not 3). Since I'm not using jruby, and this lib uses native extensions, no osgi for me. Too bad, Feedzirra looked promising.... – Daniel Ribeiro Jul 15 '10 at 01:44
  • Is this now [feedjira](https://github.com/feedjira/feedjira)? – David Moles May 12 '20 at 22:41
11

Googleage reveals some things. Were they not acceptable?

Simple RSS
Ruby-Feedparser

require 'simple-rss'
require 'open-uri'
rss = SimpleRSS.parse open('http://slashdot.org/index.rdf')
rss.channel.title # => "Slashdot"
Pistos
  • 23,070
  • 14
  • 64
  • 77
  • 2
    Simple-RSS looked good, but it hasn't been updated in 2 years. Feedparser also looked pretty good but it appears there's no gem and it's an 0.6. I was hoping there'd be something a bit more mature that's generally the standard. – aronchick Oct 19 '08 at 04:17
  • I know how you feel about wanting to use active projects, but if the RSS and RDF specs haven't changed much lately, perhaps these would do the trick. :) – Pistos Oct 19 '08 at 05:23
  • i'll give it a shot with Simple RSS - but it really surprises me that there's not a better solution out there - given how web 2.0-y Ruby/Rails and RSS are you'd think there'd be a nice package combining them. – aronchick Oct 20 '08 at 03:26
  • It's quite possible there is a rails-specific solution. I haven't googled for it, though. – Pistos Oct 20 '08 at 11:13
  • SimpleRSS have encoding issues and it's not been fixed for like 1 year. – Cheng Jul 04 '15 at 05:08
  • This answer is 9 years old. I'm thinking it should be disregarded and retired. :) – Pistos Apr 05 '17 at 05:04
11

If you meet crappy feeds, you may want to use HPricot to parse the feed.

Thibaut Barrère
  • 8,845
  • 2
  • 22
  • 27
  • Did you settle on Hpricot, I tried this and had a could not get all the information out of a feed. It did fair better than Nokogiri which could not handle malformed feeds. – Kris Sep 03 '09 at 08:38
  • Well one time or two, Hpricot could not handle some very broken feed but apart from that all the time it's working fine for me. I'm using it for http://www.learnivore.com for instance. – Thibaut Barrère Sep 15 '09 at 15:03
2

Looks like in 2009 the standart Ruby RSS library just didn't exist yet?

Nakilon
  • 34,866
  • 14
  • 107
  • 142
2

Feed Normalizer looks like it may be a good option

https://github.com/aasmith/feed-normalizer

Dave Powers
  • 2,051
  • 2
  • 30
  • 34
RichH
  • 6,108
  • 1
  • 37
  • 61
  • it looks like feed-normalizer wraps Simple RSS, from installing it. I just used it to trawl through an OPML file of mixed Rss/Atom feeds - it seemed to be very nicely agnostic, I didn't know or care what it was looking at, which suits me! – Mike Woodhouse Jan 21 '10 at 10:52
1

I like using niokrigi or scrapi for parsing the xml in the atom/rss feeds. http://www.rubyinside.com/nokogiri-ruby-html-parser-and-xml-parser-1288.html

CodeJoust
  • 3,760
  • 21
  • 23
1

I have tried Feedzirra and SimpleRSS and I found that both work great. Feedzirra was faster though so if its performance you're looking for, you're better off with Feedzirra.

janex
  • 497
  • 4
  • 14