Created
July 27, 2011 03:00
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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