Skip to content

happyFish/wikipedia-client

 
 

Repository files navigation

Wikia

Allows you to get wikia content through their API. This uses the
alpha API, not the deprecated query.php API type

Wikia API reference: https://en.wikia.org/w/api.php

Adopted from: https://code.google.com/p/wikia-client/

Installation

gem install wikia-client

Examples

require 'wikia'
page = Wikia.find( 'Getting Things Done' )

=> #<Wikia:Page>

page.title

=> 'Getting Things Done'

page.content

=> # all the wiki markup appears here...

page.categories

=> [..., "Category:Self-help books", ...]

page.links

=> [..., "Business", "Cult following", ...]

page.extlinks

=> [..., "https://www.example.com/", ...]

page.images

=> ["File:Getting Things Done.jpg", ...]

page.image_urls

=> ["https://upload.wikimedia.org/wikia/en/e/e1/Getting_Things_Done.jpg"]

page.image_descriptionurls

=> ["https://en.wikia.org/wiki/File:Getting_Things_Done.jpg"]

page.coordinates

=> [48.853, 2.3498, "", "earth"]

page.templates

=> [..., "Template:About", ...]

Configuration

This is by default configured like this:

Wikia.Configure {
  domain 'en.wikia.org'
  path   'w/api.php'
}

Advanced

See the API spec at https://en.wikia.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 = Wikia.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}}}}

Running specs

if you have rspec >= 1.1.3 installed just type in

rake spec

Thanks!

Copyright © 2008 [Cyril David], released under the MIT license

Adopted by Ken Pratt ([email protected]) in 2010/03

Packages

No packages published

Languages

  • Ruby 100.0%