def wikipedialang(urls, langs={"en","fr","pt", "it","es","ru", "ar","ja","zh", "ko","nl","pl"}): """ infer all the wikipedia languages link that are in the langs set. EXAMPLE ======= >>> wikipedialang(['http://en.wikipedia.org/wiki/Montreal'],langs={'en','fr','ru'}) ['http://fr.wikipedia.org/wiki/Montr%C3%A9al', 'http://ru.wikipedia.org/wiki/%D0%9C%D0%BE%D0%BD%D1%80%D0%B5%D0%B0%D0%BB%D1%8C', 'http://en.wikipedia.org/wiki/Montreal'] """ res = [] for url in urls: title = url_title(url) res.extend(wikipedia.langlinks(title, langs)) return res
def urltranslate(url): title = title_url(url) links = wikipedia.langlinks(title) return links