How to get the result of “all pages with prefix” using Wikipedia api?

我们两清 提交于 2019-12-12 18:03:25

问题


I wish to use Wikipedia api to extract the result of this page:

http://en.wikipedia.org/wiki/Special:PrefixIndex

When searching "something" on it, for example this:

http://en.wikipedia.org/w/index.php?title=Special%3APrefixIndex&prefix=tal&namespace=4

Then, I would like to access each of the resulting pages and extract their information.

What api call might I use?


回答1:


You can use list=allpages and specify apprefix. For example:

http://en.wikipedia.org/w/api.php?format=xml&action=query&list=allpages&apprefix=tal&aplimit=max

This query will give you the id and title of each article that starts with tal. If you want to get more information about each page, you can use this list as a generator:

http://en.wikipedia.org/w/api.php?format=xml&action=query&generator=allpages&gapprefix=tal&gaplimit=max&prop=info

You can give different values to the prop parameter to get different information about the page.



来源:https://stackoverflow.com/questions/9056497/how-to-get-the-result-of-all-pages-with-prefix-using-wikipedia-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!