Skip to content

Instantly share code, notes, and snippets.

@visnup
Created April 20, 2009 07:09
Show Gist options
  • Save visnup/98411 to your computer and use it in GitHub Desktop.
Save visnup/98411 to your computer and use it in GitHub Desktop.
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