首页 > 解决方案 > 直接获取维基百科原始标签?

问题描述

是否有一个 URL 可以直接获取 Wikipedia 条目的原始标签,而不是 HTML?也就是说,我只想得到这样的东西,

{{about|the cat species that is commonly kept as a pet|the cat family|Felidae|other uses|Cat (disambiguation)|and|Cats (disambiguation)}}....

不是,

<!DOCTYPE html>
<html class="client-nojs" lang="en" dir="ltr">
<head>
<meta charset="UTF-8"/>
<title>Cat - Wikipedia</title> ....

我搜索了谷歌,但找不到答案。我能找到的最接近的 URL 类似于https://en.wikipedia.org/w/index.php?title=Cat&action=edit,我可以从中提取标签,但它仍然包含不必要的 HTML 内容。

标签: wikipediawikipedia-api

解决方案


您所说的“标签”是Wikitext语法。可以使用“原始”操作为任何页面获取它,例如https://en.wikipedia.org/w/index.php?title=Cat&action=raw。请注意,您将获得与您使用的 action=edit 完全相同的内容,没有其他版本没有“不必要的 HTML 内容”。


推荐阅读