Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the name of Wikipedia article in other language

I'm trying to extract English Wikipedia articles related to a list of Arabic articles, let's say I have this article

https://ar.wikipedia.org/wiki/%D8%A7%D9%84%D9%82%D8%AF%D8%B3

and I need to extract the English version of it

https://en.wikipedia.org/wiki/Jerusalem

The problem is that I don't have the list of English names corresponding to the Arabic names list to use it with the API's, I think about extracting the language links and do some processing on the result to extract the English names but don't know if there is any easier way using the Mediawiki API's that you can suggest?

like image 986
Afnan Ahmad Avatar asked Oct 17 '22 22:10

Afnan Ahmad


1 Answers

The easiest way to do this is through wikidata. There's a wikidata item for all the wikipedia pages, and wikidata has links to all the wiki pages about the particular term. So, here's an example query that would give you the English name from Arabic name:

https://www.wikidata.org/w/api.php?action=wbgetentities&sites=arwiki&titles=%D8%A7%D9%84%D9%82%D8%AF%D8%B3&languages=en

like image 191
Petr Avatar answered Nov 28 '22 12:11

Petr