Allows you to get wikipedia content through their API. This uses the
alpha API, not the deprecated query.php API type
Wikipedia API reference: http://en.wikipedia.org/w/api.php
Adopted from: http://code.google.com/p/wikipedia-client/
gem install wikipedia-client
require 'wikipedia'
page = Wikipedia.find( 'Getting Things Done' )
=> #<Wikipedia:Page>
page.title
=> 'Getting Things Done'
page.fullurl
=> 'http://en.wikipedia.org/wiki/Getting_Things_Done'
page.text
=> 'Getting Things Done is a time-management method...'
page.content
=> # all the wiki markup appears here...
page.summary
=> # only the wiki summary appears here...
page.categories
=> [..., "Category:Self-help books", ...]
page.links
=> [..., "Business", "Cult following", ...]
page.extlinks
=> [..., "http://www.example.com/", ...]
page.images
=> ["File:Getting Things Done.jpg", ...]
page.image_urls
=> ["http://upload.wikimedia.org/wikipedia/en/e/e1/Getting_Things_Done.jpg"]
page.image_descriptionurls
=> ["http://en.wikipedia.org/wiki/File:Getting_Things_Done.jpg"]
page.coordinates
=> [48.853, 2.3498, "", "earth"]
page.templates
=> [..., "Template:About", ...]
This is by default configured like this:
Wikipedia.Configure {
domain 'en.wikipedia.org'
path 'w/api.php'
}
See the API spec at http://en.wikipedia.org/w/api.php
If you need data that is not already present, you can override
parameters.
For example, to retrieve only the page info:
page = Wikipedia.find( 'Getting Things Done', :prop => "info" )
page.title
=> "Getting Things Done"
page.raw_data
=> {"query"=>{"pages"=>{"959928"=>{"pageid"=>959928, "ns"=>0,
"title"=>"Getting Things Done", "touched"=>"2010-03-10T00:04:09Z",
"lastrevid"=>348481810, "counter"=>0, "length"=>7891}}}}
git clone git@github.com:kenpratt/wikipedia-client.git
cd wikipedia-client
gem install bundler
bundle exec rake spec
Edit lib/wikipedia/version.rb
, changing VERSION
.
Edit wikipedia-client.gemspec
, changing s.date
to today’s date.
Build the gem: bundle exec gem build wikipedia-client.gemspec
Commit the changes: git commit -a -m 'Version bump to 1.4.0' && git push
Publish the result to RubyGems: bundle exec gem push wikipedia-client-1.4.0.gem
Copyright © 2008 [Cyril David], released under the MIT license
Adopted by Ken Pratt (ken@kenpratt.net) in 2010/03
Aishwarya Subramanian <aishwarya923@gmail.com>
Bryce <brycedneal@gmail.com>
cdr-data <b_rhettbarber@yahoo.com>
Christian Hellsten <christian.hellsten@gmail.com>
Christopher Quackenbush <christopher@quackenbush.me>
Cyril David
Francesco Serra <afnecors@gmail.com>
ivobenedito <ivobenedito@gmail.com>
Justin Harrison <justin@matthin.com>
Ken Pratt <ken@kenpratt.net>
Manu Manu <manuisfunny@gmail.com>
Mike Haugland <mike.haugland@bravenet.com>
Pietro F. Menna <pietromenna@yahoo.com>
Sophie Rapoport <sfrapoport@gmail.com>
tsukasaoishi <tsukasa.oishi@gmail.com>
V <thevalentino@gmail.com>