通过API从MediaWiki页面获取文本内容 [英] Get Text Content from mediawiki page via API

查看:322
本文介绍了通过API从MediaWiki页面获取文本内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对MediaWiki还是很陌生,但是现在我有一个问题. 我有一些Wiki页面的标题,并且我想使用 api.php 来获取所说页面的文本,但是我在API中找到的所有内容都是获取Wiki内容的一种方式页面的页面(带有Wiki标记).我使用了这个HTTP请求...

I'm quite new to MediaWiki, and now I have a bit of a problem. I have the title of some Wiki page, and I want to get just the text of a said page using api.php, but all that I have found in the API is a way to obtain the Wiki content of the page (with wiki markup). I used this HTTP request...

/api.php?action=query&prop=revisions&rvlimit=1&rvprop=content&format=xml&titles=test

但是我只需要文本内容,不需要Wiki标记. MediaWiki API可以做到这一点吗?

But I need only the textual content, without the Wiki markup. Is that possible with the MediaWiki API?

推荐答案

我认为使用API​​仅获取文本是不可能的.

I don't think it is possible using the API to get just the text.

对我有用的是请求HTML页面(使用您将在浏览器中使用的普通URL)并在内容div下去除HTML标签.

What has worked for me was to request the HTML page (using the normal URL that you would use in a browser) and strip out the HTML tags under the content div.

使用Java的 HTML解析器,我取得了良好的效果.它提供了有关如何在给定DIV下去除HTML标记的示例.

I have had good results using HTML Parser for Java. It has examples of how to strip out HTML tags under a given DIV.

这篇关于通过API从MediaWiki页面获取文本内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆