[LRUG] Parsing RSS in Ruby

Niko Felger niko.felger at gmail.com
Fri May 3 17:52:24 PDT 2013


Hi Michael,

This is a bit of a non-answer, but if the content of those feeds isn't too
complex, you could just parse them with a generic XML parser like Nokogiri
(or whatever is fashionable now). Getting all recent LRUG meeting titles,
links and descriptions, for example, is just a few lines of code:

require 'rubygems'
require 'nokogiri'
require 'open-uri'

url = 'http://lrug.org/rss/meetings/'
doc = Nokogiri::XML(open(url) {|file| file.read})
doc.css('item').each do |item|
  puts item.at('title').text
  puts item.at('link').text
  puts item.at('description').text[0..250]
end

HTH,
Niko


On Fri, May 3, 2013 at 11:56 PM, Michael Mokrysz <sites at 46bit.com> wrote:

> Howdy,
>
> I'd like to parse a few dozen RSS feeds with Ruby, but I'm not sure how
> best to parse them. Any recommendations between RSS in Stdlib<http://www.ruby-doc.org/stdlib-2.0/libdoc/rss/rdoc/RSS.html>or a gem?
>
> Thanks,
> Michael Mokrysz
>
> _______________________________________________
> Chat mailing list
> Chat at lists.lrug.org
> http://lists.lrug.org/listinfo.cgi/chat-lrug.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lrug.org/pipermail/chat-lrug.org/attachments/20130504/70f2031f/attachment-0003.html>


More information about the Chat mailing list