mediawiki - getting a template data of a wiki page using api -


i obtain template data of wikipedia pages. have tried several api commands such parse, query, expandtemplates etc, have not been able obtain information looking for.

for example, page abraham lincoln: http://en.wikipedia.org/wiki/abraham_lincoln.

i querying templates exist page so: http://en.wikipedia.org/w/api.php?action=query&prop=templates&format=jsonfm&tllimit=500&titles=abraham_lincoln

there many templates. in particular interested in "infobox" templates. if understand results correctly, there 6 infobox templates:

  • "template:infobox u.s. cabinet"
  • "template:infobox cabinet members"
  • "template:infobox cabinet members/row"
  • "template:infobox officeholder"
  • "template:infobox officeholder/office"
  • "template:infobox officeholder/personal data"

now comes hard part. if use 'query' api so: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=abraham lincoln&continue=&rvgeneratexml=

i many templates 2 infobox templates of 6 above.

i tried use 'expandtemplates' , rvexpandtemplates recommended here: how wiki template's content?.

also tried use 'parse' described here: how result of complex wikipedia template?.

so question is: how invoke wiki api retrieve body of particular template know exist on particular title? (e.g. how "template:infobox cabinet members" of abraham lincoln).

if not possible, how 6 infobox templates particular page?

thanks.

you can parse content of template as if included on page, using action=parse. provide title of page want act (in case abraham lincoln), , use contentmodel=wikitext pass wikitext of template, (actual wikitext omitted, obvious reasons):

https://en.wikipedia.org/w/api.php?action=parse&contentmodel=wikitext&title=abraham lincoln&prop=text&text=<table class="infobox ... snip 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -