-
Notifications
You must be signed in to change notification settings - Fork 78
Images
Steve edited this page Aug 14, 2017
·
16 revisions
A page's image can come from the pageimage or thumbnail via get_query()
, from an Infobox (via get_parse()
), from Wikidata Property:P18 (via get_wikidata()
), or from the RESTBase image or thumb (via get_rest()
).
All images are stored in the images
attribute:
images = [
{'kind': 'parse-image', <imageinfo>}, # infobox['image']
{'kind': 'parse-cover', <imageinfo>}, # infobox['Cover']
{'kind': 'query-pageimage', <imageinfo>}, # query['page'][i]['pageimage']
{'kind': 'query-thumbnail', <imageinfo>}, # query['page'][i]['thumbnail']
{'kind': 'rest-image', <imageinfo>}, # rest['image']
{'kind': 'rest-thumb', <imageinfo>}, # rest['thumb']
{'kind': 'wikidata-image', <imageinfo>}, # wikidata['image']
]
Image info is supplied by get_imageinfo()
automatically:
>>> p = wptools.page().get_parse()
en.wikipedia.org (parse) Let_It_Be
en.wikipedia.org (imageinfo) File:LetItBe.jpg
...
and can be queried with the image(~kind)
method:
>>> p.image('cover')['url']
u'https://upload.wikimedia.org/wikipedia/en/2/25/LetItBe.jpg'
Further reading