im trying to extract the "also known as"-information from wikidata. E.g., by visiting the page of elvis(https://www.wikidata.org/wiki/Q303), i want to reach the information "Elvis, Elvis Aaron Presley, The King, The King Of Rock'n'Roll"
I'm using pywikibot as a script on Python 3.5.
Right know i can grab the text of the page (which seems not to contain these synonyms), as well as the Itempage with the translations on the right side.
import pywikibot
site = pywikibot.Site('en', 'wikipedia')
page = pywikibot.Page(site, 'Elvis Presley')
item = pywikibot.ItemPage.fromPage(page)
item.get() # you need to call it to access any data.
sitelinks = item.sitelinks
print(sitelinks)
Thank you in advance!
Your code looks well. You have just to fetch the aliases instead of sitelinks, e.g.:
which gives you the expected list: