如何使用单个 WIKI api 调用获取不同页面中的图像 URL? [英] How to get image URLs in different pages using a single WIKI api call?

查看:24
本文介绍了如何使用单个 WIKI api 调用获取不同页面中的图像 URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们可以通过使用管道字符 ( | ) 在单个 wiki api 调用中获取不同页面的文本提取.

We can get text extract of different pages in a single wiki api call by using pipe character ( | ).

例如:http://en.wikipedia.org/w/api.php?format=json&action=query&prop=extracts&exlimit=max&explaintext&exintro&titles=雅虎|Google&redirects=

通过使用这个api调用,我们可以以文本格式获取关于谷歌和雅虎的数据.在这里,我们在一个 api 调用中同时获得了 Google 和 Yahoo 的数据.

By using this api call, we can get datas about Google and Yahoo in text format. Here we get datas of both Google and Yahoo in a single api call.

我想在一个 wiki api 调用中同时获取 Google 和 Yahoo 的图片网址.是否有任何方法可以在单个 wiki api 调用中获取不同页面的所有图像 url?

I want to get image urls of both Google and Yahoo in a single wiki api call. Is there any method to get all image urls of different pages in a single wiki api call?

推荐答案

是的,只需将 prop=extracts 切换为 prop=images.工作方式完全相同:

Yes, just switch prop=extracts to prop=images. Works exactly the same way:

http://en.wikipedia.org/w/api.php?action=query&titles=Yahoo|Google&prop=images

完整文档在这里:http://www.mediawiki.org/wiki/API:属性

要获取图片的 url,请使用 prop=imageinfo&iiprop=url 对应的文件页面.

To get the url of an image, use prop=imageinfo&iiprop=url for the corresponding file page.

最后,您可以通过将 prop=images 结果用作 generator 用于 prop=imageinfo 调用:

Finally, you can combine it all in one single request, by using the prop=images result as a generator for the prop=imageinfo call:

http://en.wikipedia.org/w/api.php?action=query&prop=imageinfo&iiprop=url&generator=images&titles=Google|Yahoo!

这篇关于如何使用单个 WIKI api 调用获取不同页面中的图像 URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆