Closed ElieJelly closed 5 years ago
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 notifications@github.com, 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.
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. Thanks If you have a better idea for my issue don't hesitate.
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']
print(f'({lang}) {title} <{url}>')
This prints the following output:
(an) Debantero (fútbol) <https://an.wikipedia.org/wiki/Debantero_(f%C3%BAtbol)>
(ar) مهاجم (كرة قدم) <https://ar.wikipedia.org/wiki/%D9%85%D9%87%D8%A7%D8%AC%D9%85_(%D9%83%D8%B1%D8%A9_%D9%82%D8%AF%D9%85)>
(ar) مهاجم (كوره قدم) <https://arz.wikipedia.org/wiki/%D9%85%D9%87%D8%A7%D8%AC%D9%85_(%D9%83%D9%88%D8%B1%D9%87_%D9%82%D8%AF%D9%85)>
(as) Delanteru <https://ast.wikipedia.org/wiki/Delanteru>
(az) فوروارد <https://azb.wikipedia.org/wiki/%D9%81%D9%88%D8%B1%D9%88%D8%A7%D8%B1%D8%AF>
(az) Hücumçu (futbol) <https://az.wikipedia.org/wiki/H%C3%BCcum%C3%A7u_(futbol)>
(ba) Stiama (Fuassboi) <https://bar.wikipedia.org/wiki/Stiama_(Fuassboi)>
(be) Нападнік (футбол) <https://be-tarask.wikipedia.org/wiki/%D0%9D%D0%B0%D0%BF%D0%B0%D0%B4%D0%BD%D1%96%D0%BA_(%D1%84%D1%83%D1%82%D0%B1%D0%BE%D0%BB)>
(be) Нападаючы (футбол) <https://be.wikipedia.org/wiki/%D0%9D%D0%B0%D0%BF%D0%B0%D0%B4%D0%B0%D1%8E%D1%87%D1%8B_(%D1%84%D1%83%D1%82%D0%B1%D0%BE%D0%BB)>
(bg) Нападател (футбол) <https://bg.wikipedia.org/wiki/%D0%9D%D0%B0%D0%BF%D0%B0%D0%B4%D0%B0%D1%82%D0%B5%D0%BB_(%D1%84%D1%83%D1%82%D0%B1%D0%BE%D0%BB)>
(bn) আক্রমণভাগের খেলোয়াড় (ফুটবল) <https://bn.wikipedia.org/wiki/%E0%A6%86%E0%A6%95%E0%A7%8D%E0%A6%B0%E0%A6%AE%E0%A6%A3%E0%A6%AD%E0%A6%BE%E0%A6%97%E0%A7%87%E0%A6%B0_%E0%A6%96%E0%A7%87%E0%A6%B2%E0%A7%8B%E0%A6%AF%E0%A6%BC%E0%A6%BE%E0%A6%A1%E0%A6%BC_(%E0%A6%AB%E0%A7%81%E0%A6%9F%E0%A6%AC%E0%A6%B2)>
(bs) Napadač <https://bs.wikipedia.org/wiki/Napada%C4%8D>
(ca) Davanter (futbol) <https://ca.wikipedia.org/wiki/Davanter_(futbol)>
(ck) ھێرشبەر (تۆپی پێ) <https://ckb.wikipedia.org/wiki/%DA%BE%DB%8E%D8%B1%D8%B4%D8%A8%DB%95%D8%B1_(%D8%AA%DB%86%D9%BE%DB%8C_%D9%BE%DB%8E)>
(cs) Fotbalový útočník <https://cs.wikipedia.org/wiki/Fotbalov%C3%BD_%C3%BAto%C4%8Dn%C3%ADk>
(de) Stürmer (Fußball) <https://de.wikipedia.org/wiki/St%C3%BCrmer_(Fu%C3%9Fball)>
(el) Κεντρικός επιθετικός <https://el.wikipedia.org/wiki/%CE%9A%CE%B5%CE%BD%CF%84%CF%81%CE%B9%CE%BA%CF%8C%CF%82_%CE%B5%CF%80%CE%B9%CE%B8%CE%B5%CF%84%CE%B9%CE%BA%CF%8C%CF%82>
(en) Forward (association football) <https://en.wikipedia.org/wiki/Forward_(association_football)>
(es) Delantero <https://es.wikipedia.org/wiki/Delantero>
(et) Ründaja (jalgpall) <https://et.wikipedia.org/wiki/R%C3%BCndaja_(jalgpall)>
(eu) Aurrelari (futbola) <https://eu.wikipedia.org/wiki/Aurrelari_(futbola)>
(fa) مهاجم (فوتبال) <https://fa.wikipedia.org/wiki/%D9%85%D9%87%D8%A7%D8%AC%D9%85_(%D9%81%D9%88%D8%AA%D8%A8%D8%A7%D9%84)>
(fr) Attaquant (football) <https://fr.wikipedia.org/wiki/Attaquant_(football)>
(ga) Ionsaitheoir <https://ga.wikipedia.org/wiki/Ionsaitheoir>
(gl) Dianteiro <https://gl.wikipedia.org/wiki/Dianteiro>
(hr) Napadač (nogomet) <https://hr.wikipedia.org/wiki/Napada%C4%8D_(nogomet)>
(hu) Csatár (labdarúgás) <https://hu.wikipedia.org/wiki/Csat%C3%A1r_(labdar%C3%BAg%C3%A1s)>
(hy) Հարձակվող (ֆուտբոլ) <https://hy.wikipedia.org/wiki/%D5%80%D5%A1%D6%80%D5%B1%D5%A1%D5%AF%D5%BE%D5%B8%D5%B2_(%D6%86%D5%B8%D6%82%D5%BF%D5%A2%D5%B8%D5%AC)>
(id) Penyerang (sepak bola) <https://id.wikipedia.org/wiki/Penyerang_(sepak_bola)>
(it) Attaccante (calcio) <https://it.wikipedia.org/wiki/Attaccante_(calcio)>
(ja) フォワード (サッカー) <https://ja.wikipedia.org/wiki/%E3%83%95%E3%82%A9%E3%83%AF%E3%83%BC%E3%83%89_(%E3%82%B5%E3%83%83%E3%82%AB%E3%83%BC)>
(jv) Panyerang <https://jv.wikipedia.org/wiki/Panyerang>
(ka) თავდამსხმელი (ფეხბურთი) <https://ka.wikipedia.org/wiki/%E1%83%97%E1%83%90%E1%83%95%E1%83%93%E1%83%90%E1%83%9B%E1%83%A1%E1%83%AE%E1%83%9B%E1%83%94%E1%83%9A%E1%83%98_(%E1%83%A4%E1%83%94%E1%83%AE%E1%83%91%E1%83%A3%E1%83%A0%E1%83%97%E1%83%98)>
(kk) Шабуылшы <https://kk.wikipedia.org/wiki/%D0%A8%D0%B0%D0%B1%D1%83%D1%8B%D0%BB%D1%88%D1%8B>
(ko) 공격수 <https://ko.wikipedia.org/wiki/%EA%B3%B5%EA%B2%A9%EC%88%98>
(ku) Êrîşber (futbol) <https://ku.wikipedia.org/wiki/%C3%8Ar%C3%AE%C5%9Fber_(futbol)>
(lt) Puolėjas (futbolas) <https://lt.wikipedia.org/wiki/Puol%C4%97jas_(futbolas)>
(lv) Uzbrucējs (futbols) <https://lv.wikipedia.org/wiki/Uzbruc%C4%93js_(futbols)>
(mk) Напад (фудбал) <https://mk.wikipedia.org/wiki/%D0%9D%D0%B0%D0%BF%D0%B0%D0%B4_(%D1%84%D1%83%D0%B4%D0%B1%D0%B0%D0%BB)>
(mn) Хөлбөмбөгийн довтлогч <https://mn.wikipedia.org/wiki/%D0%A5%D3%A9%D0%BB%D0%B1%D3%A9%D0%BC%D0%B1%D3%A9%D0%B3%D0%B8%D0%B9%D0%BD_%D0%B4%D0%BE%D0%B2%D1%82%D0%BB%D0%BE%D0%B3%D1%87>
(mr) फॉरवर्ड (फुटबॉल) <https://mr.wikipedia.org/wiki/%E0%A4%AB%E0%A5%89%E0%A4%B0%E0%A4%B5%E0%A4%B0%E0%A5%8D%E0%A4%A1_(%E0%A4%AB%E0%A5%81%E0%A4%9F%E0%A4%AC%E0%A5%89%E0%A4%B2)>
(ms) Penyerang (bola sepak) <https://ms.wikipedia.org/wiki/Penyerang_(bola_sepak)>
(mt) Attakkant <https://mt.wikipedia.org/wiki/Attakkant>
(ne) अग्रपङ्क्ति (फुटबल) <https://ne.wikipedia.org/wiki/%E0%A4%85%E0%A4%97%E0%A5%8D%E0%A4%B0%E0%A4%AA%E0%A4%99%E0%A5%8D%E0%A4%95%E0%A5%8D%E0%A4%A4%E0%A4%BF_(%E0%A4%AB%E0%A5%81%E0%A4%9F%E0%A4%AC%E0%A4%B2)>
(nl) Aanvaller (voetbal) <https://nl.wikipedia.org/wiki/Aanvaller_(voetbal)>
(nn) Angrepsspelar i fotball <https://nn.wikipedia.org/wiki/Angrepsspelar_i_fotball>
(no) Angrepsspiller (fotball) <https://no.wikipedia.org/wiki/Angrepsspiller_(fotball)>
(oc) Atacant (fotbòl) <https://oc.wikipedia.org/wiki/Atacant_(fotb%C3%B2l)>
(pl) Napastnik <https://pl.wikipedia.org/wiki/Napastnik>
(pt) Atacante (futebol) <https://pt.wikipedia.org/wiki/Atacante_(futebol)>
(ro) Atacant (fotbal) <https://ro.wikipedia.org/wiki/Atacant_(fotbal)>
(ru) Нападающий (футбол) <https://ru.wikipedia.org/wiki/%D0%9D%D0%B0%D0%BF%D0%B0%D0%B4%D0%B0%D1%8E%D1%89%D0%B8%D0%B9_(%D1%84%D1%83%D1%82%D0%B1%D0%BE%D0%BB)>
(sc) Pizzu (punta) <https://scn.wikipedia.org/wiki/Pizzu_(punta)>
(sc) Forrit (association fitbaw) <https://sco.wikipedia.org/wiki/Forrit_(association_fitbaw)>
(si) Striker <https://simple.wikipedia.org/wiki/Striker>
(sk) Útočník (futbal) <https://sk.wikipedia.org/wiki/%C3%9Ato%C4%8Dn%C3%ADk_(futbal)>
(sq) Sulmuesi (futboll) <https://sq.wikipedia.org/wiki/Sulmuesi_(futboll)>
(sr) Нападач (фудбал) <https://sr.wikipedia.org/wiki/%D0%9D%D0%B0%D0%BF%D0%B0%D0%B4%D0%B0%D1%87_(%D1%84%D1%83%D0%B4%D0%B1%D0%B0%D0%BB)>
(sv) Anfallare (fotboll) <https://sv.wikipedia.org/wiki/Anfallare_(fotboll)>
(sz) Napadźor (fusbal) <https://szl.wikipedia.org/wiki/Napad%C5%BAor_(fusbal)>
(ta) முன்கள வீரர் (காற்பந்துச் சங்கம்) <https://ta.wikipedia.org/wiki/%E0%AE%AE%E0%AF%81%E0%AE%A9%E0%AF%8D%E0%AE%95%E0%AE%B3_%E0%AE%B5%E0%AF%80%E0%AE%B0%E0%AE%B0%E0%AF%8D_(%E0%AE%95%E0%AE%BE%E0%AE%B1%E0%AF%8D%E0%AE%AA%E0%AE%A8%E0%AF%8D%E0%AE%A4%E0%AF%81%E0%AE%9A%E0%AF%8D_%E0%AE%9A%E0%AE%99%E0%AF%8D%E0%AE%95%E0%AE%AE%E0%AF%8D)>
(tg) Ҳамлагар (футбол) <https://tg.wikipedia.org/wiki/%D2%B2%D0%B0%D0%BC%D0%BB%D0%B0%D0%B3%D0%B0%D1%80_(%D1%84%D1%83%D1%82%D0%B1%D0%BE%D0%BB)>
(th) กองหน้า <https://th.wikipedia.org/wiki/%E0%B8%81%E0%B8%AD%E0%B8%87%E0%B8%AB%E0%B8%99%E0%B9%89%E0%B8%B2>
(tr) Forvet (futbol) <https://tr.wikipedia.org/wiki/Forvet_(futbol)>
(uk) Нападник (футбол) <https://uk.wikipedia.org/wiki/%D0%9D%D0%B0%D0%BF%D0%B0%D0%B4%D0%BD%D0%B8%D0%BA_(%D1%84%D1%83%D1%82%D0%B1%D0%BE%D0%BB)>
(uz) Hujumchi <https://uz.wikipedia.org/wiki/Hujumchi>
(vi) Tiền đạo (bóng đá) <https://vi.wikipedia.org/wiki/Ti%E1%BB%81n_%C4%91%E1%BA%A1o_(b%C3%B3ng_%C4%91%C3%A1)>
(wu) 前锋 (足球) <https://wuu.wikipedia.org/wiki/%E5%89%8D%E9%94%8B_(%E8%B6%B3%E7%90%83)>
(xm) გემანთხაფალი (კუჩხბურთი) <https://xmf.wikipedia.org/wiki/%E1%83%92%E1%83%94%E1%83%9B%E1%83%90%E1%83%9C%E1%83%97%E1%83%AE%E1%83%90%E1%83%A4%E1%83%90%E1%83%9A%E1%83%98_(%E1%83%99%E1%83%A3%E1%83%A9%E1%83%AE%E1%83%91%E1%83%A3%E1%83%A0%E1%83%97%E1%83%98)>
(zh) 前鋒 <https://zh-yue.wikipedia.org/wiki/%E5%89%8D%E9%8B%92>
(zh) 前鋒 (足球) <https://zh.wikipedia.org/wiki/%E5%89%8D%E9%8B%92_(%E8%B6%B3%E7%90%83)>
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 ?