Get output of a template call in a page from MediaWiki API -
i trying parse page on wikia additional information infobox book
template on page. problem can template's source instead of transformed template on page.
i'm using following url base: http://starwars.wikia.com/api.php?format=xml&action=expandtemplates&text={{infobox%20book}}&generatexml=1
the documentation doesn't tell me how point specific page , parse transformed template page. possible or need parse myself?
to expand template parameters given page, have provide parameters. there no way api know how template used in different pages (it used twice!).
this works:
action=expandtemplates&text={{infobox book|book name=lost tribe of sith: skyborn}}
you will, of course have keep adding parameters want parse (there 14 in example).
if have templates change automatically depending on page (that not case here), e.g. making use of magic words such {{pagename}}
, can add &page=lost_tribe_of_the_sith:_skyborn
api call, set context template should expanded in.
if not know parameters given, can either:
render whole page index.php?action=render&title=lost_tribe_of_the_sith:_skyborn, , parse returned html carve out actual infobox
fetch (action=query&prop=revisions) , parse wikicode parameters template, , supply them
expandtemplates
callstart using extension semantic mediawiki, allows treat wiki more database
1 , 2 can go wrong in number of ways, of course, wiki have, definition, no way of knowing content entered in consistent way.
Comments
Post a Comment