2

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.

hakre
  • 193,403
  • 52
  • 435
  • 836
Necko
  • 179
  • 2
  • 12
  • 3
    I heard they are working on a new db system where basic information about people, towns, etc is stored in a language-neutral way. I guess these kind of queries going to be a easier in the future... – Karoly Horvath Apr 17 '12 at 09:03
  • Don't forget to accept an answer if [your question](http://stackoverflow.com/users/1338245/necko?tab=questions) is solved. By awarding good answers you make stackoverflow work. – PiTheNumber Apr 18 '12 at 12:58

2 Answers2

2

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

PiTheNumber
  • 22,828
  • 17
  • 107
  • 180
  • Thx dude, i want try this one http://en.wikipedia.org/w/api.php?action=query&prop=revisions&titles=Stack%20Overflow&rvprop=content because I want get the infobox, u think it's hard ? – Necko Apr 17 '12 at 11:30
  • So why didn't you ask for the infobox? See http://stackoverflow.com/a/10180899/956397 – PiTheNumber Apr 17 '12 at 12:13
2

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.

Repox
  • 15,015
  • 8
  • 54
  • 79
  • Thx, have u got an example how I can parse that ? I prefer json than xml so I will try to make a little json parser. – Necko Apr 17 '12 at 11:31