How to get wiki template's content?
Does anybody know how to get access to the template's body inside the page?
I'm familiar with the API that returns the list of ALL templates that exist on the page, but how I can get access to the template's body? Is there any API for th开发者_运维问答is? For now I see only one possible way... parse it manually. Am I wrong?
You can use the expandtemplates API call, or the rvexpandtemplates
parameter for the revisions API call.
This is an old question, but it helped me figure out how to fetch a mediawiki page with template macros expanded. Very useful if you are doing a conversion.
<MW_BASEURL>/api.php?action=query&prop=revisions
&titles=<url_encoded_page_title>&format=xml&rvprop=content&rvexpandtemplates
I am parsing the xml returned from this query to get the expanded page.
精彩评论