Zache added a comment.
There is bug/missing code in WikidataSPARQLPageGenerator. It works if the
entity_url and endpoint is defined in parameters
import pywikibot
import pywikibot.pagegenerators as pg
query = f"""
SELECT ?item ?value WHERE {{
?item wdt:P9478 ?value.
}} LIMIT 5
"""
site = pywikibot.Site('commons', 'commons')
site.login()
endpoint='https://commons-query.wikimedia.org/sparql'
entity_url='https://commons.wikimedia.org/entity/'
generator = pg.WikidataSPARQLPageGenerator(query, endpoint=endpoint,
site=site, entity_url=entity_url)
for item in generator:
page_id=item.getID(numeric=True)
result = list(site.load_pages_from_pageids([page_id]))
print(result)
print(page_id)
TASK DETAIL
https://phabricator.wikimedia.org/T326762
EMAIL PREFERENCES
https://phabricator.wikimedia.org/settings/panel/emailpreferences/
To: Zache
Cc: Zache, Aklapper, matej_suchanek, pywikibot-bugs-list, PotsdamLamb,
Jyoo1011, JohnsonLee01, SHEKH, Dijkstra, Khutuck, Zkhalido, Viztor, Wenyi,
Tbscho, MayS, Mdupont, JJMC89, Dvorapa, Altostratus, Avicennasis, mys_721tx,
Xqt, jayvdb, Ricordisamoa, Masti, Alchimista
_______________________________________________
pywikibot-bugs mailing list -- [email protected]
To unsubscribe send an email to [email protected]