Necko
Necko

Reputation: 179

How do I use the Wikipedia API

I want try to get tennis players description from wikipedia without scratch the DOM page on a player x. It's not allowed and very boring. So, I hope someone can reply to my only question.

What can I do precisly with the Wikipedia API ? Can I get informations about a collection of tennis players easily ? or this API is not working for this. If not, I need someone tells me what is the purpose of this API because I don't understand the documentation.

Upvotes: 2

Views: 276

Answers (2)

PiTheNumber
PiTheNumber

Reputation: 23562

You can fetch an article like this:

http://en.wikipedia.org/w/index.php?title=Stackoverflow&printable=yes

or to use the API:

http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Stack%20Overflow&rvprop=content

this will get you the raw article code. To get the html version use action=parse:

http://en.wikipedia.org/w/api.php?action=parse&format=json&page=Stack_Overflow

Also have a look at the documentation: http://www.mediawiki.org/wiki/API

Upvotes: 2

Repox
Repox

Reputation: 15474

Take a look at the Wikipedia API Sandbox - with that you can play around and try to get the info you need.

To get the info from a page, you can use the parse action.

Trying to get the information for the danish tennisplayer Caroline Wozniacki, I used the parse action along with the json format.
In the field labeled page I pasted Caroline_Wozniacki and I pressed Make Request.

This gives me this URL: http://en.wikipedia.org/w/api.php?action=parse&format=json&page=Caroline_Wozniacki
This contains the page with links, references and all in JSON format.

Upvotes: 2

Related Questions