require 'rss/2.0' require 'open-uri' class RssReader def parseFeed (url, length) feed_url = url output = ""; open(feed_url) do |http| response = http.read result = RSS::Parser.parse(response, false) output = "<span class=\"feedTitle\">#{result.channel.title}</span><br /><ul>" result.items.each_with_index do |item, i| output += "<li><a href=\"#{item.link}\">#{item.title}</a></li>" if ++i < length end output += "</ul>" end return output end end
Never been to CodeSnippets before?
Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)
simple Ruby RSS reader (See related posts)
You need to create an account or log in to post comments to this site.
Related Posts
» xml to objects in ruby xml parse object
» Example using xmlplarser's s... in ruby rails xml files parse huge saxdriver xmlplarser
» Scrape YouTube thumbnails in ruby www file video mechanize scraping youtube save scrape
» Scrape MySpace friend thumbn... in ruby www file mechanize scraping save scrape myspace
» Scrape torrents on btjunkie in ruby www file mechanize scraping save scrape btjunkie torrents bittorrent
» Simple command line rss read... in shell osx mac bash unix rss xml reader xmlstarlet
Snippets (source code soon to be available) developed by Peter Cooper and powered by Ruby On Rails