wptools icon indicating copy to clipboard operation
wptools copied to clipboard

possible to resolve macros in infobox?

Open boompig opened this issue 4 years ago • 1 comments

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.

boompig avatar May 26 '20 19:05 boompig

Thanks for trying wptools @boompig!

Great idea! We'll have to find some API point that can do that, and we'll incorporate it.

siznax avatar May 26 '20 21:05 siznax