rfeedparser snippets

Parsing feeds with Ruby and rFeedParser

Tagged rfeedparser, ruby, rss, parse, feed  Languages ruby

rFeedParser is a Ruby version of the feedparser Python library, which is probably the best (not fastest) feed parser.

To install it follow the instruction on the project's GitHub page.

require 'rubygems'
require 'rfeedparser'
require 'benchmark'

seconds = Benchmark.realtime do

    body = File.read('example-feed.xml')
    for num in (1..500)
        feed = FeedParser.parse(body) # Can be URL, string, data.

puts "#{seconds.round} elapsed."

rFeedParser has one problem. In my simple test it was ~3-4 times slower than feed-normalizer and feedparser.org.