molybdenum-99 / infoboxer

Wikipedia information extraction library
MIT License
174 stars 16 forks source link

Template#expand #57

Open zverok opened 8 years ago

zverok commented 8 years ago

Usage example:

wp.get('Iceland').infobox.fetch('population_estimate').text # => empty

It fetches link to {{Ispop}} -- it is too complex to be parsed by Infoboxer itself to extract data, but parsing can be delegated to Wikipedia itself.

# MediaWiktory code
wikipedia.expandtemplates.
  text('{{Ispop}}').prop(:wikitext).perform.raw.
  expandtemplates.wikitext # => "329,100"

# so, Infoboxer should can call it like, just
wp.get('Iceland').infobox.
  fetch('population_estimate').templates.first.expand # => "329,100"

Unfortunately, require #19 to be implemented for all non-trivial templates.