从中文维基百科中检索第一段

Retrieve first paragraph from Wikipedia in Chinese

我想检索中文维基百科的第一段。我找到了 API;

http://en.wikipedia.org/w/api.php?action=query&prop=extracts&rawcontinue=1&format=xml&exintro=&titles=samsung

但是returns数据是英文的。

如何从这个 API 获取中文数据?

维基百科不是一个站点,而是多个站点。英文维基百科上的文章 Samsung 没有中文文本,但您可能正在寻找上面调用的 corresponding page on Chinese Wikipedia. As most or all Wikipedias use the TextExtract extension,您可以简单地更改域和页面标题,并使用相同的 API 像刚才那样打电话:

http://zh.wikipedia.org/w/api.php?action=query&prop=extracts&rawcontinue=1&format=xml&exintro=&titles=%E4%B8%89%E6%98%9F%E9%9B%86%E5%9B%A2

与中文相关:根据文档,您还应该能够选择要获取的语言变体(例如 zh-tw、台湾语或 zh-cn、大陆),使用 exvariant 参数.