问题
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 this? For now I see only one possible way... parse it manually. Am I wrong?
回答1:
You can use the expandtemplates API call, or the rvexpandtemplates
parameter for the revisions API call.
回答2:
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.
来源:https://stackoverflow.com/questions/7416776/how-to-get-wiki-templates-content