Created
December 4, 2016 09:14
-
-
Save k-nut/0240051a47663d5a128e6fa9dfc80170 to your computer and use it in GitHub Desktop.
Create a new politician
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pywikibot | |
def create_bavarian_politician(name): | |
""" | |
Creates a new entry in test.wikdata.org | |
:return: | |
""" | |
site = pywikibot.Site("wikidata", "wikidata") | |
repo = site.data_repository() | |
data = { | |
'labels': { | |
'en': { | |
'language': 'en', | |
'value': name, | |
}, | |
'de': { | |
'language': 'de', | |
'value': name, | |
} | |
} | |
} | |
item = pywikibot.ItemPage(site) | |
claim = pywikibot.Claim(repo, u'P39') | |
target = pywikibot.ItemPage(repo, u"Q17586301") | |
claim.setTarget(target) | |
item.editEntity(data) | |
item.addClaim(claim) | |
create_bavarian_politician("Florian Hölzl") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment