从 Wiki 页面获取简洁的内容。 (MediaWiki API)

发布于 2024-11-27 08:24:03 字数 455 浏览 6 评论 0原文

我想以这种格式从 Wiki 获取内容页面(如下图),然后在 WebView 中显示它。这意味着内容包括文本和链接。

Einstein

我尝试了这个,但输出似乎很混乱。 http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=Albert_Einstein&format=xmlfm

I want to get a content page from Wiki in this format (the picture below) then show it in WebView. It means the content includes text and links.

Einstein

I tried this but the output seems to be messy.
http://en.wikipedia.org/w/api.php?action=query&prop=revisions&rvprop=content&titles=Albert_Einstein&format=xmlfm

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

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

发布评论

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

评论(3

就是爱搞怪 2024-12-04 08:24:04

你想要 index.php?action=render; 示例。这将返回页面内容的 HTML,不包含侧边栏/页眉/页脚 HTML。您必须自己匹配和删除信息框。

参考:MediaWiki — 手册:index.php 的参数

You want index.php?action=render; an example. This returns the HTML of the page content with no sidebar/header/footer HTML. You'll have to match and remove infoboxes yourself.

Reference: MediaWiki — Manual:Parameters to index.php.

青朷 2024-12-04 08:24:04

您可以使用 mediawiki 生成的 HTML 而不是 wikicode。

顺便说一句:看看这个

You can use HTML generated by mediawiki instead of wikicode.

BTW: look at this

浅黛梨妆こ 2024-12-04 08:24:03

一年后我偶然发现了这个答案,并想指出 ?action=render 参数 截至本文已贬值

推荐的方法是使用 Mediawiki API 解析 wiki 文本

I stumbled across this answer a year later and would like to note that the ?action=render parameter has been depreciated as of this post.

The recommended method is to use the Mediawiki API to parse the wikitext.

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