import pywikibot
import re
site = pywikibot.Site('ru', 'wikipedia')
repo = site.data_repository()
source = pywikibot.Claim(repo, 'P143')
ruwiki_item = pywikibot.ItemPage(repo, 'Q206855')
source.setTarget(ruwiki_item)
wdproperty='P2043'
page = pywikibot.Page(site, 'Туръя')
item = pywikibot.ItemPage.fromPage(page)
if 'ru' not in item.labels:
    label = page.title()
    item.editLabels(labels={'ru': label}, summary=u'Import label from Russian Wikipedia')
length_matches = re.search('\|\s*Длина\s*=\s*(\d+)\s*\|', page.text)
length = int(length_matches.group(1))
km_item_helper_string = 'http://www.wikidata.org/entity/Q828224'.format()
length_target = pywikibot.WbQuantity(length, km_item_helper_string)
if item.claims and wdproperty not in item.claims: # length
    claim = pywikibot.Claim(repo, wdproperty)
    claim.setTarget(length_target)
    item.addClaim(claim)
    claim.addSource(source, bot=True)
template_page = pywikibot.Page(site, 'Шаблон:Река')