From 046384051a6fd2aeab692263e9d533d363e45572 Mon Sep 17 00:00:00 2001 From: Pacien TRAN-GIRARD Date: Wed, 22 Oct 2014 10:30:23 +0200 Subject: Add geographic search query URL generator --- src/downloader/__init__.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'src') diff --git a/src/downloader/__init__.py b/src/downloader/__init__.py index 3a02ebe..f256ddc 100644 --- a/src/downloader/__init__.py +++ b/src/downloader/__init__.py @@ -106,3 +106,23 @@ class WikimediaAPI(): "list": "recentchanges", "rcnamespace": WikimediaAPI.RCNAMESPACES_CODES[namespace], }) + + def get_geo_pages(self, lat, long, radius, limit=500, namespace="(Main)"): + """ + Generate the query URL performing a geographic search of articles + located near the given coordinates. + + :param lat: Latitude + :param long: Longitude + :param radius: radius (in m) to look inside + :param limit: maximum number of results (max 500) + :param namespace: namespace to restrict the search in + :return: + """ + return self.gen_query_url({ + "list": "geosearch", + "gscoord": "%f|%f" % (lat, long), + "gsradius": "%f" % radius, + "gsnamespace": WikimediaAPI.RCNAMESPACES_CODES[namespace], + "gslimit": limit, + }) -- cgit v1.2.3