您好,我正在使用 Curl 从维基百科获取信息,我只想接收有关主图像的信息,我不想接收文章的所有图像..
例如..
如果我想获取有关英语语言的所有图像的信息(http://en.wikipedia.org/wiki/English_language http://en.wikipedia.org/wiki/English_language)我应该访问这个网址:但我收到了 XML 格式的说英语的国家的国旗:
<?xml version="1.0"?> <api> <query>
<normalized>
<n from="English_language" to="English language" />
</normalized>
<pages>
<page pageid="8569916" ns="0" title="English language">
<images>
<im ns="6" title="File:Anglospeak(800px)Countries.png" />
<im ns="6" title="File:Anglospeak.svg" />
<im ns="6" title="File:Circle frame.svg" />
<im ns="6" title="File:Commons-logo.svg" />
<im ns="6" title="File:Flag of Argentina.svg" />
<im ns="6" title="File:Flag of Aruba.svg" />
<im ns="6" title="File:Flag of Australia.svg" />
<im ns="6" title="File:Flag of Bolivia.svg" />
<im ns="6" title="File:Flag of Brazil.svg" />
<im ns="6" title="File:Flag of Canada.svg" />
我只想要有关主图像的信息。
There's news! (from 2014)
A new extension, PageImages https://www.mediawiki.org/wiki/Extension:PageImages, is available and also got already installed on the Wikimedia wikis.
代替prop=images
, use prop=pageimages
,你会得到一个pageimage
属性和一个<thumbnail>
每个子节点<page>
元素。
诚然,它不能保证给出最好的结果,但在你的例子中(英语 https://en.wikipedia.org/wiki/English_language) it 并且只产生地理分布图,而不是所有旗帜。
另外,开放搜索API https://www.mediawiki.org/wiki/API:Opensearch确实返回一个<image>
在它的 xml 表示中,但此 API 不能与列表一起使用,也不能与查询 API 结合使用。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)