diff options
author | Pacien TRAN-GIRARD | 2014-10-22 10:30:23 +0200 |
---|---|---|
committer | Pacien TRAN-GIRARD | 2014-10-22 10:30:23 +0200 |
commit | 046384051a6fd2aeab692263e9d533d363e45572 (patch) | |
tree | 15deed2ad993df15fba3d77c5c8a78ce3917a7b4 /src | |
parent | 362f22b854c2c2e74fc19fd4840dfb5392d0198b (diff) | |
download | wikistats-046384051a6fd2aeab692263e9d533d363e45572.tar.gz |
Add geographic search query URL generator
Diffstat (limited to 'src')
-rw-r--r-- | src/downloader/__init__.py | 20 |
1 files changed, 20 insertions, 0 deletions
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(): | |||
106 | "list": "recentchanges", | 106 | "list": "recentchanges", |
107 | "rcnamespace": WikimediaAPI.RCNAMESPACES_CODES[namespace], | 107 | "rcnamespace": WikimediaAPI.RCNAMESPACES_CODES[namespace], |
108 | }) | 108 | }) |
109 | |||
110 | def get_geo_pages(self, lat, long, radius, limit=500, namespace="(Main)"): | ||
111 | """ | ||
112 | Generate the query URL performing a geographic search of articles | ||
113 | located near the given coordinates. | ||
114 | |||
115 | :param lat: Latitude | ||
116 | :param long: Longitude | ||
117 | :param radius: radius (in m) to look inside | ||
118 | :param limit: maximum number of results (max 500) | ||
119 | :param namespace: namespace to restrict the search in | ||
120 | :return: | ||
121 | """ | ||
122 | return self.gen_query_url({ | ||
123 | "list": "geosearch", | ||
124 | "gscoord": "%f|%f" % (lat, long), | ||
125 | "gsradius": "%f" % radius, | ||
126 | "gsnamespace": WikimediaAPI.RCNAMESPACES_CODES[namespace], | ||
127 | "gslimit": limit, | ||
128 | }) | ||