goldsmith / Wikipedia

A Pythonic wrapper for the Wikipedia API
https://wikipedia.readthedocs.org/
MIT License
2.88k stars 519 forks source link

Is there a way to access "translations"? of a certain page? #144

Open ghost opened 7 years ago

ghost commented 7 years ago

as in the title. I am able to fetch a page from Wikipedia, but it would be nice to get the name of the page to which current page refers to as "translations" in different languages. Is there a way to do it?

martin-majlis commented 6 years ago

You can try to migrate to Wikipedia-API. It's very straightforward.

import wikipediaapi
wiki = wikipediaapi.Wikipedia('de')
p = wiki.page('Deutsche Sprache')
print(p.fullurl)
print(p.summary[0:60])
p_langs = p.langlinks
p_en = p_langs['en']
print(p_en.fullurl)
print(p_en.summary[0:60])

Outputs

https://de.wikipedia.org/wiki/Deutsche_Sprache
Die deutsche Sprache bzw. Deutsch [dɔʏ̯t͡ʃ], abgekürzt Dt. o
https://en.wikipedia.org/wiki/German_language
German (Deutsch [ˈdɔʏt͡ʃ] ( listen)) is a West Germanic lang