-
I need to scrap the label of the Wikipedia links you find in every Wikidata pages in several languages for a traduction exercise i'm doing.. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Could you elaborate with a more detailed scenario, like “I want to get an output like this for this input”?
…On Jun 17, 2019 17:32 +0900, ElieJelly ***@***.***>, wrote:
I need to scrap the label of the Wikipedia links you find in every Wikidata pages in several languages for a traduction exercise i'm doing..
Can you please help me ?
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Beta Was this translation helpful? Give feedback.
-
Sorry, I'd like to have as input the entity like Client.get('Q280658', load=True) and then using the "get" or something to have an output with the list of Wikipedia links label you find in the screenshot (in fact i just need a more accurate traduction of several words than using GoogleTrad).. I've been trying all the Wiki Query "P..." but none of them are helpful. |
Beta Was this translation helpful? Give feedback.
-
Although there is no straightforward way to get these Wikipedia links and labels (yet), you can fumble about in 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']
print(f'({lang}) {title} <{url}>') This prints the following output:
|
Beta Was this translation helpful? Give feedback.
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 forQ280658
: