I would like to obtain template data of wikipedia pages. I have tried several api commands such as parse, query, expandtemplates etc, but have not been able to obtain all the information that I was looking for.
For example, the page about Abraham Lincoln: http://en.wikipedia.org/wiki/Abraham_Lincoln.
I querying which templates exist for this page like so: http://en.wikipedia.org/w/api.php?action=query&prop=templates&format=jsonfm&tllimit=500&titles=Abraham_Lincoln
There are many templates. In particular I am interested in the "infobox" templates. If I understand the results correctly, there are 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 the hard part. If I use 'query' API like so: http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&format=json&titles=Abraham Lincoln&continue=&rvgeneratexml=
I get many templates but only 2 Infobox templates of the 6 above.
I also tried to use the 'expandtemplates' and rvexpandtemplates as recommended here: How to get wiki template's content?.
Also tried to use 'parse' as described here: How to get the result of a complex Wikipedia template?.
So my question is: how do I invoke the wiki api to retrieve the body of a particular template that I know which exist on a particular title? (e.g. how to get the "Template:Infobox cabinet members" of Abraham Lincoln).
If that is not possible, then how do I get all 6 infobox templates for that particular page?
Thanks.