Created
February 6, 2009 16:16
-
-
Save wijet/59458 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 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
unless ARGV[0] and ARGV[1] | |
puts "Usage: ruby appleblogtv.rb url number_of_winners" | |
exit | |
end | |
commentators = [] | |
doc = Hpricot(open(ARGV[0])) | |
(doc/'div#commentlist//div.content/b').each do |commentator| | |
commentators << ((commentator/'a').first || commentator).inner_html.gsub(/:$/, '') | |
end | |
commentators = commentators.uniq | |
ARGV[1].to_i.times do |i| | |
puts commentators.delete_at(rand(commentators.size)) | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment