Skip to content

Instantly share code, notes, and snippets.

@youpy
Created April 20, 2012 01:23
Show Gist options
  • Save youpy/2425165 to your computer and use it in GitHub Desktop.
Save youpy/2425165 to your computer and use it in GitHub Desktop.
# encoding: utf-8
require 'json'
require 'open-uri'
require 'nkf'
require 'cgi'
url_pattern = 'http://clients1.google.co.jp/complete/search?client=hp&hl=ja&q=%s'
content = NKF.nkf('-w', open(url_pattern % CGI.escape(ARGV.shift)).read)
content.sub!(/^[^\(]+\((.+)\)$/, '\1')
data = JSON.parse(content)
data.shift
data = data[0].map do |d|
d[0]
end
puts data.join("\n")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment