【问题标题】:Using the Wikipedia API to retrieve the list of contents from a page使用 Wikipedia API 从页面检索内容列表
【发布时间】:2016-11-24 13:33:33
【问题描述】:

我想从这个 wiki 页面https://en.wikipedia.org/wiki/Outline_of_academic_disciplines 中提取学科列表,并且我想知道如何使用 Wikipedia API 来实现。

我尝试如下:https://en.wikipedia.org/w/api.php?action=parse&page=List_of_action_films_of_the_2010s&contentmodel=wikitext&prop=wikitext&format=json

但这只是检索文章的第一部分,我想检索内容部分,所以结果看起来像这样:

{
Arts : {
"Performing Arts" : [all its sub-child],
"Visual arts" : [all its sub-child]
}
Geography: {....}

}

这可以使用 Wikipedia API 吗?

【问题讨论】:

    标签: rest api wikipedia wikipedia-api


    【解决方案1】:

    action=parse&format=json&page=Outline_of_academic_disciplines&prop=sections:

    "sections": [
            {
                "toclevel": 1,
                "level": "2",
                "line": "Arts",
                "number": "1",
                "index": "1",
                "fromtitle": "Outline_of_academic_disciplines",
                "byteoffset": 1241,
                "anchor": "Arts"
            },
            {
                "toclevel": 2,
                "level": "3",
                "line": "Performing arts",
                "number": "1.1",
                "index": "2",
                "fromtitle": "Outline_of_academic_disciplines",
                "byteoffset": 1279,
                "anchor": "Performing_arts"
            },
            ...
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-03
      • 1970-01-01
      相关资源
      最近更新 更多