Skip to content

Instantly share code, notes, and snippets.

@photomattmills
Last active June 28, 2016 22:22
Show Gist options
  • Save photomattmills/c6d584e104178cd53c83f0296b4cdca5 to your computer and use it in GitHub Desktop.
Save photomattmills/c6d584e104178cd53c83f0296b4cdca5 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'open-uri'
require 'csv'
uri = URI('http://xi.hope.net/schedule.html')
html = Net::HTTP.get(uri)
entries = html[2601..-1752].split('<h3')
CSV.open("/tmp/schedule.csv", "wb")do |csv|
entries.each do |entry|
lines = entry.split("\n")
if lines.length == 4
title = lines[0].match(/<strong>(.*)<\/strong>/)[1]
author = lines[1].match(/<strong>(.*)<\/strong>/)[1]
desc = lines[2].match(/<p>(.*)<\/p>/)[1]
time = lines[3].match(/<strong>(.*)<\/strong>/)[1]
csv << [title, author, desc, time]
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment