Created
April 20, 2009 07:09
-
-
Save visnup/98411 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 'scrubyt' | |
google_data = Scrubyt::Extractor.define do | |
fetch 'http://www.google.com/search?hl=en&q="guarded by a dragon"' | |
excerpt "//div[@class=s]" | |
next_page '//td/a', :limit => ARGV.shift.to_i || 3 | |
end | |
google_data.to_hash.each do |p| | |
phrase = p.values.first.sub(/([[:punct:]] *)?guarded by a dragon.*/, '') | |
phrase.sub!(/.+[[:punct:]]/, '') # blah blah - phrase guarded by a dragon | |
phrase.sub!(/.+\b(a|an|the|but|this)\b/i, '') | |
phrase.sub!(/\b(is|was|being)\s*$/i, '') | |
puts phrase.strip.downcase | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment