Skip to content

Instantly share code, notes, and snippets.

@jikkujose
Created August 31, 2013 08:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jikkujose/6396890 to your computer and use it in GitHub Desktop.
Save jikkujose/6396890 to your computer and use it in GitHub Desktop.
Simple script in Ruby to get Google's suggested search terms
#! /usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
google_query_url = 'http://www.google.co.in/search?&q='
search_query = 'drath note'
if ARGV.length == 0 then
puts "usage: suggest <approx> <wrds> <to> <srch>"
exit
end
search_query = ARGV.join('+')
search_url = google_query_url + search_query
# puts "Search url: " + search_url
search_page = open( search_url ).read()
google_suggest = Nokogiri::HTML( search_page ).css('#topstuff span.spell + a').text
puts google_suggest unless google_suggest.length == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment