Skip to content

Instantly share code, notes, and snippets.

@wijet
Created February 6, 2009 16:16
Show Gist options
  • Save wijet/59458 to your computer and use it in GitHub Desktop.
Save wijet/59458 to your computer and use it in GitHub Desktop.
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