Skip to content

Instantly share code, notes, and snippets.

@batchblue
Created January 30, 2009 22:06
Show Gist options
  • Save batchblue/55293 to your computer and use it in GitHub Desktop.
Save batchblue/55293 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'open-uri'
require 'hpricot'
doc = open("http://rinexus.com/blog/2009/01/rhode-island-twitter-sound") { |f| Hpricot(f) }
twits = []
(doc/'.content/p').each do |p|
p.inner_html.each do |line|
matches = line.scan(/@(\w+)/m)
twits.concat(matches) unless matches.empty?
end
end
twits.flatten!
twits.uniq!
twits.each do |twit|
puts twit
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment