首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何从维基百科页面获取标题

如何从维基百科页面获取标题
EN

Stack Overflow用户
提问于 2012-11-20 02:10:29
回答 1查看 232关注 0票数 1

有没有直接的API调用,我可以从维基百科页面上获取标题。

例如,从http://en.wikipedia.org/wiki/Chicago中,我希望检索以下内容:

1历史

*1.1快速增长和发展

-1.2 20世纪和21世纪

2地理位置

2.1地形图

*2.2气候

3城市景观

第3.1版架构

等等

我已经看过http://www.mediawiki.org/wiki/API:Lists/All了,但在维基页面上找不到能给我上面列表的动作。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-11-20 04:56:00

您需要的不是页面列表,因此它不在您链接的页面上。但是可以检索某些页面的部分标题的列表。要做到这一点,您可以在prop=sections中使用action=parse

例如,http://en.wikipedia.org/w/api.php?format=xml&action=parse&prop=sections&page=Chicago返回

代码语言:javascript
复制
<api>
    <parse title="Chicago">
        <sections>
            <s toclevel="1" level="2" line="History" number="1" index="1" fromtitle="Chicago" byteoffset="8123" anchor="History"/>
            <s toclevel="2" level="3" line="Rapid growth and development" number="1.1" index="2" fromtitle="Chicago" byteoffset="12922" anchor="Rapid_growth_and_development"/>
            <s toclevel="2" level="3" line="20th and 21st centuries" number="1.2" index="3" fromtitle="Chicago" byteoffset="21558" anchor="20th_and_21st_centuries"/>
            <s toclevel="1" level="2" line="Geography" number="2" index="4" fromtitle="Chicago" byteoffset="28176" anchor="Geography"/>
            …
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/13459598

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档