Accessing main picture of wikipedia page by API

前端 未结 14 1994
没有蜡笔的小新
没有蜡笔的小新 2020-11-30 18:15

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?

14条回答
  •  一生所求
    2020-11-30 18:44

    I there is a way to reliably get a main image for a wikipedia page - the Extension called PageImages

    The PageImages extension collects information about images used on a page.

    Its aim is to return the single most appropriate thumbnail associated with an article, attempting to return only meaningful images, e.g. not those from maintenance templates, stubs or flag icons. Currently it uses the first non-meaningless image used in the page.

    https://www.mediawiki.org/wiki/Extension:PageImages

    Just add the prop pageimages to your API Query:

    /w/api.php?action=query&prop=pageimages&titles=Somepage&format=xml
    

    This reliably filters out annoying default images and prevents you from having to filter them yourself! The extension is installed on all the main wikipedia pages...

提交回复
热议问题