wptools
wptools copied to clipboard
possible to resolve macros in infobox?
When running
page = wptools.page(title)
d = page.get_parse()
pprint(d.data['infobox'])
many fields include the Wikipedia macros used to generate those values. This can be useful, but it also means re-implementing the Wikipedia macros. Is there any way to have these resolved in the output?
Here is an example:
title = 'Scott Aitchison'
page = wptools.page(title)
d = page.get_parse()
pprint(d.data['infobox'])
output:
{'name': 'Scott Aitchison',
'honorific-suffix': '{{post-nominals|country|=|CAN|MP|size|=|100%}}',
'image': 'Scott Aitchison (cropped).jpg',
'caption': 'Aitchison in 2014',
'imagesize': '200px',
'riding': '[[Parry Sound—Muskoka]]',
'parliament': 'Canadian',
'term_start': 'October 21, 2019',
'predecessor': '[[Tony Clement]]',
'birth_date': '{{circa|1973}}',
'birth_place': '[[Huntsville, Ontario]], Canada',
'party': '[[Conservative Party of Canada]]'}
So for example for the birth_date
the return value is a macro that requires the user to parse it.
Thanks for trying wptools @boompig!
Great idea! We'll have to find some API point that can do that, and we'll incorporate it.