如何获取wiki模板的内容?

发布于 2024-12-04 16:14:28 字数 236 浏览 3 评论 0 原文

有谁知道如何访问页面内的模板主体?

我熟悉返回存在的所有模板列表的 API 在页面上,但是我如何才能访问模板的主体呢?有这方面的API吗?目前我只看到一种可能的方法...手动解析它。我错了吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

浅唱ヾ落雨殇 2024-12-11 16:14:28

您可以使用 expandtemplates API 调用,或 rvexpandtemplates 参数修订 API 调用。

You can use the expandtemplates API call, or the rvexpandtemplates parameter for the revisions API call.

眼眸里的那抹悲凉 2024-12-11 16:14:28

这是一个老问题,但它帮助我弄清楚如何获取扩展了模板宏的 mediawiki 页面。如果您正在进行转换,则非常有用。

<MW_BASEURL>/api.php?action=query&prop=revisions
   &titles=<url_encoded_page_title>&format=xml&rvprop=content&rvexpandtemplates

我正在解析从此查询返回的 xml 以获取扩展页面。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文