forked from wikimedia/mediawiki-api-demos
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgeoimagesearch.py
More file actions
36 lines (25 loc) · 723 Bytes
/
geoimagesearch.py
File metadata and controls
36 lines (25 loc) · 723 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#This file is auto-generated. See modules.json and autogenerator.py for details
#!/usr/bin/python3
"""
geoimagesearch.py
MediaWiki API Demos
Demo of `Geosearch` module: Use generator module
to get search results for pages near Wikimedia HQ
with images
MIT License
"""
import requests
S = requests.Session()
URL = "https://en.wikipedia.org/w/api.php"
PARAMS = {
"action": "query",
"format": "json",
"ggscoord": "37.7891838|-122.4033522",
"generator": "geosearch",
"prop": "coordinates|pageimages"
}
R = S.get(url=URL, params=PARAMS)
DATA = R.json()
PLACES = DATA['query']['pages']
for k, v in PLACES.items():
print(str(v['title']) + ": " + str(v['thumbnail']['source']))