Last active
June 28, 2016 22:22
-
-
Save photomattmills/c6d584e104178cd53c83f0296b4cdca5 to your computer and use it in GitHub Desktop.
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
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