Want to stay on top? Ruby Weekly is a once-weekly e-mail newsletter covering the latest Ruby and Rails news.
     Feed Icon

Feedalizer: Easy Webpage to RSS Conversion from Ruby

By Peter Cooper / August 11, 2006

Flizer-1

Feedalizer is a Ruby library that lets you easily scrape Web pages and convert them into RSS feeds. Some demo code that generates a feed:

require "feedalizer"
require "time"

url = "http://sydsvenskan.se/serier/nemi/article101047.ece?context=serie"

feedalize(url) do
  feed.title = "Nemi"
  feed.about = "..."
  feed.description = "Daily Nemi strip scraped from Sydsvenskan"

  scrape_items("option") do |rss_item, html_element|
    rss_item.link  = html_element.attributes["value"]
    rss_item.date  = Time.parse(html_element.innerHTML)
    rss_item.title = rss_item.date.strftime("%Y-%m-%d")

    # This grabs the page for a particular strip and extracts the relevant img element
    rss_item.description = grab_page(rss_item.link).search("//img[@width=748]")
  end

  output!
end

Other Posts to Enjoy

Twitter Mentions