Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible to resolve macros in infobox? #154

Open
boompig opened this issue May 26, 2020 · 1 comment
Open

possible to resolve macros in infobox? #154

boompig opened this issue May 26, 2020 · 1 comment
Labels

Comments

@boompig
Copy link

boompig commented May 26, 2020

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.

@siznax
Copy link
Owner

siznax commented May 26, 2020

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 siznax added the Feature label May 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants