Created
November 7, 2011 21:39
-
-
Save greggroth/1346276 to your computer and use it in GitHub Desktop.
Process The Porter's List
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 "nokogiri" | |
require "open-uri" | |
require "yaml" | |
# Let's check out The Porter's selection | |
doc = Nokogiri::HTML(open('http://www.theporterbeerbar.com/drink/beer/')) | |
puts "Loaded the website OK" | |
# Make an array to hold all of the data | |
data = Array.new | |
# Fill the array with the data from each row | |
doc.css('tr').each { |row| data << row.content.delete("\t").split(/\n/) } | |
# Remove the heading row | |
data.shift | |
# Save the data | |
out = File.new("beer_menu.yml", "w") | |
out.write(data.to_yaml) | |
# Give the user a notice | |
puts "Found #{data.count} listings and wrote the array to 'beer_menu.yml'" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment