Skip to content

Instantly share code, notes, and snippets.

@stevenocchipinti
Created July 27, 2011 03:00
Show Gist options
  • Save stevenocchipinti/1108569 to your computer and use it in GitHub Desktop.
Save stevenocchipinti/1108569 to your computer and use it in GitHub Desktop.
This parses an rss feed for dates that could be used to form an ical
# rss_to_ical.rb
#
# This parses a (specific) rss feed for dates that could be used to form an ical
require 'nokogiri'
require 'open-uri'
require 'time'
# Configuration
url = "http://melbournepatterns.org/feed/"
xpath = "//item//title"
regex = /<title>Next meeting: ([^)]*)<\/title>/
doc = Nokogiri::HTML(open(url))
doc.xpath(xpath).each do |node|
node.to_s.scan(regex) do |matches|
# Create Date object to use in the ical
date = Time.parse(matches[0])
puts "#{matches[0]} == #{date.to_s}"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment