Skip to content

Instantly share code, notes, and snippets.

@omoshetech-t
Last active September 8, 2015 11:19
Show Gist options
  • Save omoshetech-t/e6d8a25e4667e46af251 to your computer and use it in GitHub Desktop.
Save omoshetech-t/e6d8a25e4667e46af251 to your computer and use it in GitHub Desktop.
Japanese SEO keyword suggestion tool.
require 'json'
require 'open-uri'
def complete(query)
q = URI.escape(query)
url = "http://suggestqueries.google.com/complete/search?q=#{q}&client=firefox&hl=ja"
json = open(url).read
JSON.parse(json).last
end
keywords = ARGV.join(' ')
abort("Usage: ruby #{$0} keyword ...") if keywords.empty?
chars = (?a..?z).to_a + (?ァ..?ヶ).to_a
puts chars.map { |char| complete("#{keywords} #{char}") }
.flatten.uniq.sort
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment