是否维基百科的API支持搜索特定模板? [英] Does the Wikipedia API support searches for a specific template?
问题描述
是否可以查询包含特定模板文章维基百科的API? 未介绍会过滤搜索结果包含一个模板页面的任何行动的文件。具体来说,我认为包含网页模板后:Persondata code>。在那之后,我希望能够以填充为 openancestry.org 项目。
Is it possible to query the Wikipedia API for articles that contain a specific template? The documentation does not describe any action that would filter search results to pages that contain a template. Specifically, I am after pages that contain Template:Persondata
. After that, I am hoping to be able to retrieve just that specific template in order to populate genealogy data for the openancestry.org project.
下面的查询显示,爱因斯坦页包含Persondata模板,但它不返回模板的内容,我不知道如何获得包含模板页面标题的列表。
<一href=\"http://en.wikipedia.org/w/api.php?action=query&prop=templates&titles=Albert%20Einstein&tlcontinue=736|10|ParmPart\">http://en.wikipedia.org/w/api.php?action=query&prop=templates&titles=Albert%20Einstein&tlcontinue=736|10|ParmPart
The query below shows that the Albert Einstein page contains the Persondata Template, but it doesn't return the contents of the template, and I don't know how to get a list of page titles that contain the template. http://en.wikipedia.org/w/api.php?action=query&prop=templates&titles=Albert%20Einstein&tlcontinue=736|10|ParmPart
返回:
<api>
<query>
<pages>
<page pageid="736" ns="0" title="Albert Einstein">
<templates>
...
<tl ns="10" title="Template:Persondata"/>
...
</templates>
</page>
</pages>
</query>
<query-continue>
<templates tlcontinue="736|10|Reflist"/>
</query-continue>
</api>
我怀疑,我不能让我从API需要的,但我希望我是错的,并且有人已经走出了一条小道沿着这条道路。
I suspect that I can't get what I need from the API, but I'm hoping I'm wrong and that someone has already blazed a trail down this path.
推荐答案
您可以使用 embeddedin
查询发现,包括该模板的所有网页:
You can use the embeddedin
query to find all pages that include the template:
curl 'http://en.wikipedia.org/w/api.php?action=query&list=embeddedin&eititle=Template:Persondata&eilimit=5&format=xml'
它可以帮助您:
<?xml version="1.0"?>
<api>
<query>
<embeddedin>
<ei pageid="307" ns="0" title="Abraham Lincoln" />
<ei pageid="308" ns="0" title="Aristotle" />
<ei pageid="339" ns="0" title="Ayn Rand" />
<ei pageid="340" ns="0" title="Alain Connes" />
<ei pageid="344" ns="0" title="Allan Dwan" />
</embeddedin>
</query>
<query-continue>
<embeddedin eicontinue="10|Persondata|595" />
</query-continue>
</api>
请参阅全文档在mediawiki.org。
See full docs at mediawiki.org.
修改使用 embeddedin
查询,而不是反向
(其中不包括模板夹杂物)
Edit Use embeddedin
query instead of backlinks
(which doesn't cover template inclusions)
这篇关于是否维基百科的API支持搜索特定模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!