You know that the url address is wrong
API doc.
For this use Requests.
Here a demo,i use string formatting to make changes in url address.
Test run.
googleis
?API doc.
For this use Requests.
Here a demo,i use string formatting to make changes in url address.
import requests address = '1600 Amphitheatre Parkway Mountain View' api_key = 'Your API key' url = 'https://maps.googleapis.com/maps/api/geocode/json?address={}{}'.format(''.join(address.split()), api_key) url_get = requests.get(url) loc = url_get.json()What you get back is a Python dictionary also contain list when come from JSON.
Test run.
>>> loc['results'][0]['geometry'] {'bounds': {'northeast': {'lat': 37.42198310000001, 'lng': -122.0853195}, 'southwest': {'lat': 37.4214139, 'lng': -122.0860042}}, 'location': {'lat': 37.4216548, 'lng': -122.0856374}, 'location_type': 'ROOFTOP', 'viewport': {'northeast': {'lat': 37.4230474802915, 'lng': -122.0843128697085}, 'southwest': {'lat': 37.4203495197085, 'lng': -122.0870108302915}}} >>> loc['results'][0]['geometry']['location'] {'lat': 37.4216548, 'lng': -122.0856374} >>> loc['results'][0]['geometry']['location']['lat'] 37.4216548