5.1.1 Image - Siege III: The Fortress of Raab occupied by the Turks, 1594. Painting, https://wikibase.wbworkshop.tibwiki.io/wiki/Item:Q505
The below Python code experiments with retrieving data from Wikibase using the API. This takes approx. 18 seconds to run due to the size of the images.
from PIL import Imageimport requests# Global variablesendpoint_url ='https://wikibase.wbworkshop.tibwiki.io'resource_url ='/w/api.php'entity_id ='Q505'def get_entity (entity_id): resourceUrl ='/w/api.php?action=wbgetentities&format=json&ids='+entity_id uri = endpoint_url + resourceUrl r = requests.get(uri) data = r.json()return datamedia_data = get_entity(entity_id)claims = media_data['entities'][entity_id]['claims']forproperty, values in claims.items():ifproperty=='P22':for value in values: image_url = value['mainsnak']['datavalue']['value'] im = Image.open(requests.get(image_url, stream=True).raw)elifproperty=='P23':for value in values: entity_id = value['mainsnak']['datavalue']['value']['id'] object_data = get_entity(entity_id)print('English title: ', object_data['entities'][entity_id]['labels']['en']['value'])display(im)
English title: Siege III: The Fortress of Raab occupied by the Turks, 1594