-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|675|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
SoCoder -> Snippet Home -> Internet


 
HoboBen
Created : 07 August 2010
Edited : 07 August 2010

Wikipedia/MediaWiki API example

Short examples showing how to get information from MediaWiki (e.g. Wikipedia) websites

Works for any MediaWiki website. In this example, I'm using wikipedia.

To get a MediaWiki website's license info, use:

en.wikipedia.org/w/api.php?action=query&meta=siteinfo&siprop=rightsinfo&format=xml

To get an article's text contents:

en.wikipedia.org/w/api.php?action=parse&page=Manic_street_preachers&format=xml&redirects&prop=text

Note "&redirects" - without this, the page "Manic_street_preachers" won't work, because wikipedia expects the correct case of "Manic_Street_Preachers". This also works with other types of redirect, e.g. the "UK" wikipedia page redirects to "United Kingdom".

Note there are formats other than XML: json, jsonfm, php, phpfm, wddx, wddxfm, xml, xmlfm, yaml, yamlfm, rawfm, txt, txtfm, dbg, dbgfm


Full API

 

Comments


Saturday, 07 August 2010, 04:40
Jayenkai
Cool!

Not sure if I'd ever make use of it, but nice to know it's out there!
Monday, 09 August 2010, 01:43
waroffice
My site uses mediawiki, Doghousedean.com

Looks like it works