jsonbashparsingmediawiki-apiwikimedia-commons

Get deeplinks of Wikimedia Commons pictures


I would like to get the fulltext URL from Wikimedia Commons pictures. As example I would like to get https://upload.wikimedia.org/wikipedia/commons/6/69/Trittin%2C_J%C3%BCrgen-0126.jpg from File:Trittin, Jürgen-0126.jpg. Here is the html source:

<div class="fullMedia"><a href="https://upload.wikimedia.org/wikipedia/commons/6/69/Trittin%2C_J%C3%BCrgen-0126.jpg" class="internal" title="Trittin, Jürgen-0126.jpg">Original file</a> &#8206;<span class="fileInfo">(1,996 × 3,000 pixels, file size: 2.2 MB, MIME type: <span class="mime-type">image/jpeg</span>)</span>
</div>

Because I'm doing many queries I would prefer a lightweight unix tools solution over such a thing like BeautifulSoup. There is also an API (commons.wikimedia.org/w/api.php?action=query&prop=imageinfo&titles=File:Trittin,_J%C3%BCrgen-0126.jpg&iiprop=url), but for me as a simple bash scripter JSON is an imposition!

I'm glad if you could help me.


Solution

  • Replace in URL

    File:
    

    with

    Special:FilePath/