Created
September 15, 2011 03:02
-
-
Save damncabbage/1218418 to your computer and use it in GitHub Desktop.
Polite Dinner Suggestions
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
#!/usr/bin/env ruby | |
# | |
# ruby dinner.rb [number-of-dinners] | |
# | |
require 'rubygems'; | |
require 'open-uri'; | |
require 'hpricot'; | |
recipes = Integer(ARGV[0] || 5) | |
recipes.times do |i| | |
doc = open("http://whatthefuckshouldimakefordinner.com"){ |f| Hpricot(f) } | |
(doc/"dl").each do |e| | |
puts "#{e.inner_text.strip}:" | |
break | |
end unless i > 0 | |
(doc/"dt/a").each do |e| | |
puts " * #{e.inner_text}" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment