Use import wikipedia
. If you don't have it, use pip install wikipedia
.
Great. Now for the coordinates.
Let's say you want to find the coordinates of Beijing, China. (You need to specify the country.)
import wikipedia as wiki
page = wiki.page("China")
coordinates = page.coordinates
print(coordinates)
This will output:
(Decimal('39.90666666999999989684511092491447925567626953125'), Decimal('116.3974999999999937472239253111183643341064453125'))
.
See! That simple. No API. I assure you, if you go to PyPI and search "wikipedia", you will find the wikipedia package.