Wikidata talk:Pywikibot - Python 3 Tutorial/Changing Items

From Wikidata
Jump to navigation Jump to search

The example from this page is a bit outdated; WDQ has been shut down. @Tobias1984: you may want to update it. --XXN, 13:43, 7 July 2017 (UTC)[reply]

@XXN: Thanks for the ping. A lot has also changed in the pywikibot in the mean time. But at the moment I don't have much time to keep the tutorial up to date. --Tobias1984 (talk) 13:18, 8 July 2017 (UTC)[reply]
Here is a working example with WikidataSPARQLPageGenerator instead of the outdated WikidataQueryPageGenerator in the for loop of the code:
for key in error_dict:
    wdq = 'SELECT DISTINCT ?item WHERE {{ ?item p:{0} ?statement0. ?statement0 (ps:{0}) wd:{1}. }} LIMIT 5'.format(property, key)
    generator = pg.WikidataSPARQLPageGenerator(wdq, site=site)
    correct_claim(generator, key)
Singlespeedfahrer (talk) 22:21, 18 October 2021 (UTC)[reply]