我正在寻找某种方法来检索某个关键字(也是主题)的所有相关主题。例如,对于关键字“ Pizza”,我想要得到类似的内容:[“ Food”,“ Italian”,“ Cheese” ....]。有什么办法可以使用Wikipedia API?谢谢!
答案 0 :(得分:2)
最容易想到的是文章类别。 有关如何使用API检索它们的信息,请参阅API:Categories。 例如,文章pizza具有以下non-hidden类别:
{
"continue": {
"clcontinue": "24768|Popular_culture",
"continue": "||"
},
"query": {
"pages": {
"24768": {
"pageid": 24768,
"ns": 0,
"title": "Pizza",
"categories": [
{
"ns": 14,
"title": "Category:Cheese dishes"
},
{
"ns": 14,
"title": "Category:Convenience foods"
},
{
"ns": 14,
"title": "Category:Flatbread dishes"
},
{
"ns": 14,
"title": "Category:Greek inventions"
},
{
"ns": 14,
"title": "Category:Italian-American cuisine"
},
{
"ns": 14,
"title": "Category:Italian cuisine"
},
{
"ns": 14,
"title": "Category:Italian inventions"
},
{
"ns": 14,
"title": "Category:Mediterranean cuisine"
},
{
"ns": 14,
"title": "Category:National dishes"
},
{
"ns": 14,
"title": "Category:Pizza"
}
]
}
}
}
}
您可以通过https://en.wikipedia.org/w/api.php?action=query&prop=categories&titles=Pizza&clshow=!hidden进行检索。
与dog类似:https://en.wikipedia.org/w/api.php?action=query&prop=categories&titles=Dog&clshow=!hidden