How to get location of the Wikipedia article with Mediawiki API in terms of city/country? Let's say I want to determine what country, what city the Sagrada Familia cathedral is located in? What property should I use?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Try the following query:
https://en.wikipedia.org/w/api.php?action=query&prop=coordinates&titles=Sagrada%20Fam%C3%ADlia&coprop=country|type|name|dim|region
And see Extension:GeoData for documentation.
I'm not sure if we can get the city name using Wikipedia API, but there are some ways to convert a coordinate to a city name, see: Given the lat/long coordinates, how can we find out the city/country? or use a SPARQL query on wikidata. (the query is a copy of the one in this answer, with radius and coordinates changed.)