Skip to content

Instantly share code, notes, and snippets.

@hamajyotan
Created October 23, 2014 15:41
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 hamajyotan/5d85e1e7aa9db7976e65 to your computer and use it in GitHub Desktop.
Save hamajyotan/5d85e1e7aa9db7976e65 to your computer and use it in GitHub Desktop.
get wikipedia content by wikipedia api
#!/usr/bin/env ruby
# Usage: ./hoge KEYWORD
#
# ./hoge Java
# =>
# 名前 Java<br/> パラダイム 構造化プログラミング 構造化・命令型プログラミング...
#
require 'net/http'
require 'json'
Net::HTTP.start('wikipedia.simpleapi.net') do |http|
res = http.get("/api?keyword=#{ARGV[0]}&output=json")
JSON.parse(r.body).each do |b|
puts b['body']
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment