我在python中使用wiki api来获取各种维基百科页面的类别和子类别。我遇到的麻烦是我在拉类别页面的子类别(特别是每个子类别的pageId)时收到更多信息,但当我拉出同一类别页面的类别时,我只获得页面标题和不是pageId。
这是我在运行页面请求时获得的内容"类别:基于类的编程语言"这是我正在使用的网址: https://en.wikipedia.org/w/api.php?action=query&prop=categories&format=jsonfm&titles=Category:Class-based_programming_languages
"pages": {
"909420": {
"pageid": 909420,
"ns": 14,
"title": "Category:Class-based programming languages",
"categories": [
{
"ns": 14,
"title": "Category:Object-oriented programming languages"
}
这是我在运行同一页面的请求时获得的,但查找子类别。这是我正在使用的网址:https://en.wikipedia.org/w/api.php?action=query&format=jsonfm&list=categorymembers&cmnamespace=14&cmlimit=100&cmtitle=Category:Class-based_programming_languages
"query": {
"categorymembers": [
{
"pageid": 3623580,
"ns": 14,
"title": "Category:C++"
},
{
"pageid": 44668068,
"ns": 14,
"title": "Category:Java (programming language)"
},
{
"pageid": 44667679,
"ns": 14,
"title": "Category:Ruby (programming language)"
}
我想在搜索类别时检索pageId。我错过了网址中的参数吗?