How to get image URL in wiki api?

泄露秘密 提交于 2019-12-21 00:14:12

问题


When I call wiki APIs for accessing image URLs, I get image URLs like this,

File:Ad-tech London 2010 (2).JPG

How to get the correct URL of this file from wiki API?


回答1:


You can get the propert URLs from an imageinfo query like this:

https://en.wikipedia.org/w/api.php?action=query&titles=File:Test.jpg&prop=imageinfo&iilimit=50&iiend=2007-12-31T23:59:59Z&iiprop=timestamp|user|url

More info at MediaWiki API Help.




回答2:


There's little documentation on image/thumbnail URLs besides T153497. You can use Special:FilePath and/or thumb.php:

  • https://commons.wikimedia.org/wiki/Special:FilePath/Ad-tech_London_2010_(2).JPG
  • https://commons.wikimedia.org/wiki/Special:FilePath/Ad-tech_London_2010_(2).JPG?width=200 (to get a thumbnail of 200px width)
  • https://commons.wikimedia.org/w/thumb.php?f=Ad-tech_London_2010_(2).JPG&w=200


来源:https://stackoverflow.com/questions/30781455/how-to-get-image-url-in-wiki-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!