Similar to the OpenStreetMap task and transition APIs .
To build our request, go to overpass turbo (a good interface for the Overpass API), open the wizard and enter "wikipedia = * to London", because we are interested in the wikipedia tag .
An automatically generated and executed request will be like this.
[out:json][timeout:25]; // fetch area "London" to search in {{geocodeArea:London}}->.searchArea; // gather results ( // query part for: "wikipedia=*" node["wikipedia"](area.searchArea); way["wikipedia"](area.searchArea); relation["wikipedia"](area.searchArea); ); // print results out body; >; out skel qt;
This will result in the return of too many elements, which also heavily burden your browser. And it may fail due to a too low timeout.
We will change it a little. We increase the timeout and delete the recursion step ( >; ), because we are only interested in direct results, and not any related objects. The resulting query will be as follows:
[out:json][timeout:90]; // fetch area "London" to search in {{geocodeArea:London}}->.searchArea; // gather results ( // query part for: "wikipedia=*" node["wikipedia"](area.searchArea); way["wikipedia"](area.searchArea); relation["wikipedia"](area.searchArea); ); // print results out body; out skel qt;
Here you can see the result.
Now for its export there are various options. You can export by turbocharging and either save the results directly to a file or receive an unprocessed request that is sent to the Overpass API. Now you can run this request directly from your python script.
Note that there are available output formats : JSON, XML, and CVS. And next to the wikipedia tag, you may also be interested in the wikidata tag .
Also note that this will not lead to all Wikipedia pages with coordinates within London, only those contained in the OSM database.