2016-11-24 142 views
0

我想从此维基页面https://en.wikipedia.org/wiki/Outline_of_academic_disciplines中提取学科列表,我想知道如何使用维基百科API执行此操作。使用维基百科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: {....} 

} 

这可能使用维基百科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" 
     }, 
     ...