-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_ramenshop.py
43 lines (35 loc) · 1.12 KB
/
get_ramenshop.py
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
37
38
39
40
41
42
43
import urllib.request
import urllib.parse
import json
apikey = "AIzaSyAOqwUYekkyQ4y3EgmXmhST4oMqckVmiVU"
def get_ramenshop(location, radius):
url = (
"https://maps.googleapis.com/maps/api/place/nearbysearch/json?language=ja&key="
+ apikey
+ "&location="
+ str(location["lat"])
+ ","
+ str(location["lng"])
+ "&radius="
+ str(radius)
+ "&keyword="
+ urllib.parse.quote("ラーメン屋")
)
req = urllib.request.Request(url)
with urllib.request.urlopen(req) as res:
body = json.load(res)
return list(
map(
lambda shop: {
"name": shop["name"],
"place_id": shop["place_id"],
"location": shop["geometry"]["location"],
"rating": shop["rating"],
"opening_now": shop["opening_hours"]["open_now"],
},
body["results"],
)
)
# return body["results"]
if __name__ == "__main__":
print(get_ramenshop({"lat": 34.9821826, "lng": 135.9610467}, 4000))