如何使用 API 从维基百科页面获取 "Scientific Classification" 信息?

How to get the "Scientific Classification" information from Wikipedia page using API?

我要查询的文章是:https://en.wikipedia.org/wiki/Aplomado_falcon

我可以使用他们的 api 获取介绍信息和图像,方法是按以下格式输入我的搜索词:https://en.wikipedia.org/api/rest_v1/page/summary/[my_search_term],在我的例子中是:https://en.wikipedia.org/api/rest_v1/page/summary/Aplomado_falcon

这个returns:

{
type: "standard",
title: "Aplomado falcon",
displaytitle: "Aplomado falcon",
namespace: {
id: 0,
text: "",
},
wikibase_item: "Q773651",
titles: {
canonical: "Aplomado_falcon",
normalized: "Aplomado falcon",
display: "Aplomado falcon",
},
pageid: 1594971,
thumbnail: {
source: "https://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Aplomado_Falcon_portrait.jpg/213px-Aplomado_Falcon_portrait.jpg",
width: 213,
height: 320,
},
originalimage: {
source: "https://upload.wikimedia.org/wikipedia/commons/2/21/Aplomado_Falcon_portrait.jpg",
width: 517,
height: 775,
},
lang: "en",
dir: "ltr",
revision: "976684434",
tid: "a872bb90-f494-11ea-b097-e5e16a6eb297",
timestamp: "2020-09-04T11:10:10Z",
description: "species of falcon",
description_source: "central",
content_urls: {
desktop: {
page: "https://en.wikipedia.org/wiki/Aplomado_falcon",
revisions: "https://en.wikipedia.org/wiki/Aplomado_falcon?action=history",
edit: "https://en.wikipedia.org/wiki/Aplomado_falcon?action=edit",
talk: "https://en.wikipedia.org/wiki/Talk:Aplomado_falcon",
},
mobile: {
page: "https://en.m.wikipedia.org/wiki/Aplomado_falcon",
revisions: "https://en.m.wikipedia.org/wiki/Special:History/Aplomado_falcon",
edit: "https://en.m.wikipedia.org/wiki/Aplomado_falcon?action=edit",
talk: "https://en.m.wikipedia.org/wiki/Talk:Aplomado_falcon",
},
},
extract: "The aplomado falcon is a medium-sized falcon of the Americas. The species' largest contiguous range is in South America, but not in the deep interior Amazon Basin. It was long known as Falco fusco-coerulescens or Falco fuscocaerulescens, but these names are now believed to refer to the bat falcon. Its resemblance in shape to the hobbies accounts for its old name orange-chested hobby. Aplomado is an unusual Spanish word for "lead-colored", referring to the blue-grey areas of the plumage – an approximate English translation would be "plumbeous falcon". Spanish names for the species include halcón aplomado and halcón fajado ; in Brazil it is known as falcão-de-coleira.",
extract_html: "<p>The <b>aplomado falcon</b> is a medium-sized falcon of the Americas. The species' largest contiguous range is in South America, but not in the deep interior Amazon Basin. It was long known as <i>Falco fusco-coerulescens</i> or <i>Falco fuscocaerulescens</i>, but these names are now believed to refer to the bat falcon. Its resemblance in shape to the hobbies accounts for its old name <b>orange-chested hobby</b>. <i>Aplomado</i> is an unusual Spanish word for "lead-colored", referring to the blue-grey areas of the plumage – an approximate English translation would be "plumbeous falcon". Spanish names for the species include <i><b>halcón aplomado</b></i> and <i><b>halcón fajado</b></i> ; in Brazil it is known as <i><b>falcão-de-coleira</b></i>.</p>",
}

如何通过 api 以 json 格式获取 return 科学信息以及保护状况以及上述信息?

维基百科的 API 不会提供与页面内容相关的结构化数据。对于此类服务,请查看维基数据。您提供的 API 的输出包含:

wikibase_item: "Q773651",

这是wikidata实体的key,见https://www.wikidata.org/wiki/Q773651

另一种方法是获取原始维基百科页面内容并使用自定义解析器分析模板内容。