Skip to content

Instantly share code, notes, and snippets.

@greggroth
Created November 7, 2011 21:39
Show Gist options
  • Save greggroth/1346276 to your computer and use it in GitHub Desktop.
Save greggroth/1346276 to your computer and use it in GitHub Desktop.
Process The Porter's List
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