我正在寻找某种方法来检索某个关键字(也是一个主题)的所有相关主题。例如,对于关键字“披萨”,我想要得到类似的内容:[“食物”、“意大利”、“奶酪”......]。有没有办法使用维基百科 API 来做到这一点?谢谢!
最佳答案
我想到的最接近的是文章类别。 有关如何使用 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
关于api - 维基百科 API 相关主题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51230294/