Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想从 Wikimedia commons 下载符合特定条件的所有图像。
此 API 调用为我提供了与搜索词“编程”匹配的 5 个图像的图像 URL:
http://commons.wikimedia.org/w/api.php?action=query&list=allimages&ailimit=5&aifrom=Programming&aiprop=dimensions|url
但是,URL 指的是全尺寸图像。如何以编程方式访问较小的版本?
好吧,您需要将查询从 更改list=allimages为prop=imageinfo,而是将列表用作生成器。然后对于 imageinfo,您可以iiurlwidth根据需要指定。
list=allimages
prop=imageinfo
iiurlwidth
宽度为 500 的示例: http ://commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&format=json&iiprop=url%7Cdimensions&iiurlwidth=500&titles=Programming&generator=allimages