Accessing Wikipedia Data from PAWS

by J. Nathan Matias

Based on example code at https://wikitech.wikimedia.org/wiki/PAWS

import pywikibot as pb

## EXAMPLE CODE FROM POWERPOINT LINKED AT THE BOTTOM OF THIS PAGE:
## https://wikitech.wikimedia.org/wiki/PAWS

commons_site = pb.Site("commons", "commons")
page = pb.Page(commons_site, 'File:Salar de Tara, Chile, 2016-02-07, DD 64-67 PAN.jpg')
print("Page Exists: {0}".format(page.exists()))
print("Page Title: {0}".format(page.title()))
print("Page is File Page: {0}".format(page.is_filepage()))
Page Exists: True
Page Title: File:Salar de Tara, Chile, 2016-02-07, DD 64-67 PAN.jpg
Page is File Page: True
print("==== REVISIONS TO THIS PAGE ====")
print("")
print([x for x in page.revisions()])
==== REVISIONS TO THIS PAGE ====

[{'revid': 300152893, 'text': None, 'timestamp': Timestamp(2018, 5, 8, 6, 53, 59), 'user': 'Jdx', 'anon': False, 'comment': 'Added Polish description', 'minor': True, 'rollbacktoken': None, '_parent_id': 281387836, '_content_model': 'wikitext', '_sha1': '82e565ead3bf1220f411f34fd02298a309c343de'}, {'revid': 281387836, 'text': None, 'timestamp': Timestamp(2018, 1, 20, 23, 51, 45), 'user': 'Ira Leviton', 'anon': False, 'comment': "Deleted a duplicate 'the'.", 'minor': True, 'rollbacktoken': None, '_parent_id': 270273552, '_content_model': 'wikitext', '_sha1': 'a42c08c77e34572680fd83fdf385494b05200059'}, {'revid': 270273552, 'text': None, 'timestamp': Timestamp(2017, 12, 2, 14, 12, 58), 'user': 'WeHaKa', 'anon': False, 'comment': 'removed [[Category:Antofagasta Region]] using [[Help:Gadget-HotCat|HotCat]]', 'minor': True, 'rollbacktoken': None, '_parent_id': 260898447, '_content_model': 'wikitext', '_sha1': '57d1a89a905f298c1a320760f2dcd44ae0689645'}, {'revid': 260898447, 'text': None, 'timestamp': Timestamp(2017, 10, 2, 10, 25, 1), 'user': 'SteinsplitterBot', 'anon': False, 'comment': 'Bot: Removing deprecated template', 'minor': True, 'rollbacktoken': None, '_parent_id': 240222811, '_content_model': 'wikitext', '_sha1': 'a419556db01b5d3aac98c040c6cefae7507f6663'}, {'revid': 240222811, 'text': None, 'timestamp': Timestamp(2017, 4, 9, 15, 0, 48), 'user': 'Poco a poco', 'anon': False, 'comment': 'desc, potd', 'minor': False, 'rollbacktoken': None, '_parent_id': 235640431, '_content_model': 'wikitext', '_sha1': '7d7350aec0a80a6c2c36fe56bb9f30e5ad96ae59'}, {'revid': 235640431, 'text': None, 'timestamp': Timestamp(2017, 3, 1, 16, 7, 50), 'user': 'Halavar', 'anon': False, 'comment': '', 'minor': False, 'rollbacktoken': None, '_parent_id': 235640323, '_content_model': 'wikitext', '_sha1': '93e7b8175ed91fa2b70a0b1dabf4040fcc5a749a'}, {'revid': 235640323, 'text': None, 'timestamp': Timestamp(2017, 3, 1, 16, 6, 11), 'user': 'Halavar', 'anon': False, 'comment': 'removed [[Category:Quality images of nature]]; added [[Category:Quality images of nature in Chile]] using [[Help:Gadget-HotCat|HotCat]]', 'minor': True, 'rollbacktoken': None, '_parent_id': 235624833, '_content_model': 'wikitext', '_sha1': 'dc23b44b5729fc9e90646fa0ef82ef6560a29ca8'}, {'revid': 235624833, 'text': None, 'timestamp': Timestamp(2017, 3, 1, 13, 6, 46), 'user': 'FPCBot', 'anon': False, 'comment': 'FPC promotion', 'minor': False, 'rollbacktoken': None, '_parent_id': 235622201, '_content_model': 'wikitext', '_sha1': '89c93973fde9851b0d03696bff9620c81fc7a8e5'}, {'revid': 235622201, 'text': None, 'timestamp': Timestamp(2017, 3, 1, 12, 29, 41), 'user': 'Poco a poco', 'anon': False, 'comment': '-[[Category:FP candidates by User:Poco a poco, checked]]; + 5 categories using [[Help:Gadget-HotCat|HotCat]]', 'minor': False, 'rollbacktoken': None, '_parent_id': 235179138, '_content_model': 'wikitext', '_sha1': 'ab296f0fafe718c60df17ed9bcd6217a7bd74da4'}, {'revid': 235179138, 'text': None, 'timestamp': Timestamp(2017, 2, 25, 22, 13, 58), 'user': 'Poco a poco', 'anon': False, 'comment': 'Poco a poco uploaded a new version of [[File:Salar de Tara, Chile, 2016-02-07, DD 64-67 PAN.jpg]]', 'minor': False, 'rollbacktoken': None, '_parent_id': 235134442, '_content_model': 'wikitext', '_sha1': '4bc98117c11d2449e5e73a1485f7385aaa7f9c9f'}, {'revid': 235134442, 'text': None, 'timestamp': Timestamp(2017, 2, 25, 13, 29, 56), 'user': 'Poco a poco', 'anon': False, 'comment': 'Doing 1 replacements. Using [[COM:VFC|VisualFileChange]].', 'minor': False, 'rollbacktoken': None, '_parent_id': 234996078, '_content_model': 'wikitext', '_sha1': '4bc98117c11d2449e5e73a1485f7385aaa7f9c9f'}, {'revid': 234996078, 'text': None, 'timestamp': Timestamp(2017, 2, 24, 17, 16, 34), 'user': 'Poco a poco', 'anon': False, 'comment': '[[Help:Cat-a-lot|Cat-a-lot]]: Moving from [[Category:Quality images of Chile]] to [[Category:Antofagasta Region]]', 'minor': False, 'rollbacktoken': None, '_parent_id': 234995373, '_content_model': 'wikitext', '_sha1': 'f031e016b9164f79eab4356b3254c9bae986cf09'}, {'revid': 234995373, 'text': None, 'timestamp': Timestamp(2017, 2, 24, 17, 12, 46), 'user': 'Poco a poco', 'anon': False, 'comment': 'cats', 'minor': False, 'rollbacktoken': None, '_parent_id': 234892491, '_content_model': 'wikitext', '_sha1': 'd85a9a95001964a7c22910f88608cbbd8c481d5f'}, {'revid': 234892491, 'text': None, 'timestamp': Timestamp(2017, 2, 23, 23, 34, 17), 'user': 'Daniel Case', 'anon': False, 'comment': 'added [[Category:Landscapes of Chile]] using [[Help:Gadget-HotCat|HotCat]]', 'minor': True, 'rollbacktoken': None, '_parent_id': 234681347, '_content_model': 'wikitext', '_sha1': 'bdb4c3082746dd9838a1dd9fad4d9a5f45dc547f'}, {'revid': 234681347, 'text': None, 'timestamp': Timestamp(2017, 2, 22, 5, 11, 17), 'user': 'QICbot', 'anon': False, 'comment': 'Bot: Tag promoted Quality Image', 'minor': False, 'rollbacktoken': None, '_parent_id': 234304972, '_content_model': 'wikitext', '_sha1': '3e487c8455791d2bbebf9e12cbc2081638105f8c'}, {'revid': 234304972, 'text': None, 'timestamp': Timestamp(2017, 2, 19, 14, 15, 2), 'user': 'Poco a poco', 'anon': False, 'comment': 'removed [[Category:FP candidates by User:Poco a poco]]; added [[Category:FP candidates by User:Poco a poco, checked]] using [[Help:Gadget-HotCat|HotCat]]', 'minor': True, 'rollbacktoken': None, '_parent_id': 234296649, '_content_model': 'wikitext', '_sha1': '27f2a335be780fbae1c7a91cc555cce28222f19c'}, {'revid': 234296649, 'text': None, 'timestamp': Timestamp(2017, 2, 19, 12, 32, 22), 'user': 'Poco a poco', 'anon': False, 'comment': 'Poco a poco uploaded a new version of [[File:Salar de Tara, Chile, 2016-02-07, DD 64-67 PAN.jpg]]', 'minor': False, 'rollbacktoken': None, '_parent_id': 234295005, '_content_model': 'wikitext', '_sha1': '93283241ca14bfbbd8749a17051be0b84a7dbab7'}, {'revid': 234295005, 'text': None, 'timestamp': Timestamp(2017, 2, 19, 12, 9, 23), 'user': 'Poco a poco', 'anon': False, 'comment': 'Poco a poco moved page [[File:Salar de Tara, Chile, 2016-02-07, DD 64-68 PAN.JPG]] to [[File:Salar de Tara, Chile, 2016-02-07, DD 64-67 PAN.jpg]]', 'minor': True, 'rollbacktoken': None, '_parent_id': 221656440, '_content_model': 'wikitext', '_sha1': '93283241ca14bfbbd8749a17051be0b84a7dbab7'}, {'revid': 221656440, 'text': None, 'timestamp': Timestamp(2016, 11, 27, 17, 46, 30), 'user': 'AkBot', 'anon': False, 'comment': 'Category:Uploaded with UploadWizard removed per [[Commons:Categories for discussion/2016/08/Category:Uploaded with UploadWizard|community decision]]', 'minor': True, 'rollbacktoken': None, '_parent_id': 195660823, '_content_model': 'wikitext', '_sha1': '93283241ca14bfbbd8749a17051be0b84a7dbab7'}, {'revid': 195660823, 'text': None, 'timestamp': Timestamp(2016, 5, 8, 17, 55, 13), 'user': 'Poco a poco', 'anon': False, 'comment': 'added [[Category:FP candidates by User:Poco a poco]] using [[Help:Gadget-HotCat|HotCat]]', 'minor': True, 'rollbacktoken': None, '_parent_id': 195298962, '_content_model': 'wikitext', '_sha1': '0845e4b579c7f01f24550c5a9e6fb7b1ae91395e'}, {'revid': 195298962, 'text': None, 'timestamp': Timestamp(2016, 5, 5, 13, 13, 36), 'user': 'Poco a poco', 'anon': False, 'comment': '[[Help:Cat-a-lot|Cat-a-lot]]: Adding [[Category:Images by User:Poco a poco taken in 2016]]', 'minor': False, 'rollbacktoken': None, '_parent_id': 195297816, '_content_model': 'wikitext', '_sha1': '8c2b28180e22008817a8f80bf70015b6cf735112'}, {'revid': 195297816, 'text': None, 'timestamp': Timestamp(2016, 5, 5, 12, 56, 33), 'user': 'Poco a poco', 'anon': False, 'comment': 'User created page with UploadWizard', 'minor': False, 'rollbacktoken': None, '_parent_id': 0, '_content_model': 'wikitext', '_sha1': 'd45bdb8524592be57e287896fb3e6da43b63e65f'}]