-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_google.py
31 lines (25 loc) · 953 Bytes
/
test_google.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
import requests, json, os
from dotenv import load_dotenv
load_dotenv()
headers = {
'Content-Type': 'application/json',
"X-Goog-Api-Key": os.getenv('GOOGLE_API_KEY'),
"X-Goog-FieldMask": "places.id,places.displayName,places.location,places.googleMapsUri,places.rating,places.userRatingCount," \
"places.internationalPhoneNumber,places.priceLevel,places.regularOpeningHours,places.reviews,places.photos,places.editorialSummary"
}
data = json.dumps({
"includedTypes": ["restaurant"],
"maxResultCount": 1,
"locationRestriction": {
"circle": {
"center": {
"latitude": os.getenv('LAT'),
"longitude": os.getenv('LONG')},
"radius": 16093.4
}
}
})
r = requests.post('https://places.googleapis.com/v1/places:searchNearby', data=data, headers=headers)
print(json.loads(r.content))
with open('out.json', 'w') as f:
f.write(json.dumps(json.loads(r.content), indent=4))