Skip to content

Instantly share code, notes, and snippets.

@momota10s
Created September 29, 2021 04:52
Show Gist options
  • Save momota10s/ab90939a180499fff3e25061d4f8154a to your computer and use it in GitHub Desktop.
Save momota10s/ab90939a180499fff3e25061d4f8154a to your computer and use it in GitHub Desktop.
import requests
address = "東京都千代田区千代田"
api_key = ""
requestUrl = f'https://maps.googleapis.com/maps/api/geocode/json?address="{address}"&key={api_key}&sensor=false'
r = requests.get(requestUrl).json()
if(r['results'] == []):
print("non result")
lat = None
lng = None
else:
print(r['results'][0]['geometry']['location'])
lat = r['results'][0]['geometry']['location']['lat']
lng = r['results'][0]['geometry']['location']['lng']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment