问题
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.)
来源:https://stackoverflow.com/questions/51918641/get-location-with-wikimedia-api