Hi all, I want to do the following: I want to extract all templates from a Wikipedia page with pywikibot.extract_templates_and_params(pagetext), that works fine. Now for certain fields in certain templates I want to parse the parameter itself. Or better said: I want to resolve (is this the correct term?) any included templates in such parameters, so basically I want to get the wikitext after parsing any templates within such parameters. As an example if my description is a bit too vague: I have this template {{Infobox number number = 4 following-number = {{add_one_and_link_it|4}} }}
The wikitext returned by the "add_one_and_link_it" template would be "[[5]]". Now, can I do this with pywikibot, too? Pass some string (in my case: extracted from a template) to a function and the bot will pass this to Wikipedia to get the final wikitext (I want to parse that wikitext)?
Frank
Frank Wein wrote:
Hi all, I want to do the following: I want to extract all templates from a Wikipedia page with pywikibot.extract_templates_and_params(pagetext), that works fine. Now for certain fields in certain templates I want to parse the parameter itself. Or better said: I want to resolve (is this the correct term?) any included templates in such parameters, so basically I want to get the wikitext after parsing any templates within such parameters. As an example if my description is a bit too vague: I have this template {{Infobox number number = 4 following-number = {{add_one_and_link_it|4}} }}
The wikitext returned by the "add_one_and_link_it" template would be "[[5]]". Now, can I do this with pywikibot, too? Pass some string (in my case: extracted from a template) to a function and the bot will pass this to Wikipedia to get the final wikitext (I want to parse that wikitext)?
Frank
Ok, after quite some more research I found what I was looking for :) pywikibot.Site().expand_text(...) this does what I want.
Frank
pywikipedia-l@lists.wikimedia.org