-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgoo_setup.py
More file actions
48 lines (41 loc) · 1.31 KB
/
goo_setup.py
File metadata and controls
48 lines (41 loc) · 1.31 KB
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
44
45
46
#!/usr/bin/python
import urllib, json
#Grabbing and parsing the JSON data
def GoogPlac(lat,lng,radius,types,key):
#making the url
AUTH_KEY = key
LOCATION = str(lat) + "," + str(lng)
RADIUS = radius
TYPES = types
if TYPES == None:
MyUrl = ('https://maps.googleapis.com/maps/api/place/nearbysearch/json'
'?location=%s'
'&radius=%s'
'&sensor=false&key=%s') % (LOCATION, RADIUS, AUTH_KEY)
else:
MyUrl = ('https://maps.googleapis.com/maps/api/place/nearbysearch/json'
'?location=%s'
'&radius=%s'
'&types=%s'
'&sensor=false&key=%s') % (LOCATION, RADIUS, TYPES, AUTH_KEY)
#grabbing the JSON result
response = urllib.urlopen(MyUrl)
jsonRaw = response.read()
jsonData = json.loads(jsonRaw)
return jsonData
def GoogPlac_name(lat, lng, name, radius, key):
#making the url
AUTH_KEY = key
LOCATION = str(lat) + "," + str(lng)
RADIUS = radius
NAME = name
MyUrl = ('https://maps.googleapis.com/maps/api/place/nearbysearch/json'
'?location=%s'
'&radius=%s'
'&keyword=%s'
'&key=%s') % (LOCATION, RADIUS, NAME, AUTH_KEY)
#grabbing the JSON result
response = urllib.urlopen(MyUrl)
jsonRaw = response.read()
jsonData = json.loads(jsonRaw)
return jsonData