Skip to content

NOT AN ISSUE : Having problem finding data on Wikidata #48

Answered by dahlia
ElieJelly asked this question in Q&A
Discussion options

You must be logged in to vote

Although there is no straightforward way to get these Wikipedia links and labels (yet), you can fumble about in attributes for them. Here's an example code to print Wikipedia links and labels of all available languages for Q280658:

from wikidata.client import Client

client = Client()
entity = client.get('Q280658', load=True)

for sitelink in entity.attributes['sitelinks'].values():
    # A sitelink looks like:
    # {
    #   'site': 'enwiki',
    #   'title': 'Forward (association football)',
    #   'badges': [],
    #   'url': 'https://en.wikipedia.org/wiki/Forward_(association_football)'
    # }
    lang = sitelink['site'][:2]
    title = sitelink['title']
    url = sitelink['url']
    

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dahlia
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #17 on August 04, 2022 17:29.