Manual:Pywikibot/harvest template.py

From MediaWiki.org
Jump to: navigation, search

Other languages:
Deutsch • ‎English • ‎español • ‎suomi • ‎français • ‎italiano • ‎polski • ‎português do Brasil
Bug blank.svg
Wikimedia Git repository has this file:

harvest_template.py is a script to mass add Wikidata claims based on information harvested from Wikipedia templates.

Concept[edit | edit source]

Templates on Wikipedia, especially infoboxes, contain a lot of useful information that can be used to add claims to Wikidata items.

Syntax[edit | edit source]

The bot expects a generator, the name of the template and pairs the field in the template and the property to store this in. The command will look like:

python harvest_template.py <some generator> \
    -template:<name of template> \
    <field A> P1 <field B> P3 \

This is an actual command with real values:

python harvest_template.py -lang:nl -cat:Sisoridae \
    -template:"Taxobox straalvinnige" -namespace:0 \
    orde P70 familie P71 geslacht P74

The bot will automatically figure out whether to parse an item property or to use a string property.

Depending on your configuration, you may need to specify which site to pull the template from. You can do this with -lang:XX -family:wikipedia where XX is the language code of the wiki you want to use.