访问由API维基百科页面的主画面 [英] Accessing main picture of wikipedia page by API

查看:135
本文介绍了访问由API维基百科页面的主画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法,我可以使用API​​访问任何维基百科页面的缩略图?我的意思是在顶部右侧框中的图像。是否有任何的API是什么?

Is there any way I can access the thumbnail picture of any wikipedia page by using an API? I mean the image on the top right side in box. Is there any APIs for that?

推荐答案

http://en.wikipedia.org/w /api.php

道具=图像

它返回一个是在解析的页面中使用的图像文件名的数组。然后,您可以让另一个API调用的选项找出完整的图像的URL,例如:
<$c$c>action=query&titles=Image:INSERT_EXAMPLE_FILE_NAME_HERE.jpg&prop=imageinfo&iiprop=url

It returns an array of image filenames that are used in the parsed page. You then have the option of making another API call to find out the full image URL, e.g.: action=query&titles=Image:INSERT_EXAMPLE_FILE_NAME_HERE.jpg&prop=imageinfo&iiprop=url

或<一个href=\"http://commons.wikimedia.org/wiki/FAQ#What_are_the_strangely_named_components_in_file_paths.3F\">calculate通过文件名的hash 的URL。

不幸的是,虽然按道具=图像返回图像阵列是顺序排列在页面上发现,第一,不能保证在图像信息框,因为有时一个页面将包括信息框之前的图像(大部分为有关页面的元数据时图标:如这篇文章已被锁定)

Unfortunately, while the array of images returned by prop=images is in the order they are found on the page, the first can not be guaranteed to be the image in the info box because sometimes a page will include an image before the infobox (most of the time icons for metadata about the page: e.g. "this article is locked").

搜索包括网页标题的第一图像的图像的阵列可能是用于信息框图像的最佳猜测。

Searching the array of images for the first image that includes the page title is probably the best guess for the infobox image.

这篇关于访问由API维基百科页面的主画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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