2

I've been trying to work with the google maps api and i keep getting this error:

"HTTPError: HTTP Error 403:Forbidden."

take for example this simple case (its based on a more elaborate case where i extract the adress from an XML):

from googlemaps import GoogleMaps
import xml.etree.ElementTree as et
gmaps = GoogleMaps()
pars = et.XMLParser(encoding='utf-8')
tree = et.parse('data.xml',parser=pars)
root = tree.getroot()
adress = "ringelblum 7 beer sheva"
lat , lng = gmaps.address_to_latlng(adress)
print lat, lng 

i've seen different videos and tutorials and it should be very simple. why doesnt it work? Thanks a lot guys.

2
  • Do any of these results help? Commented Aug 10, 2014 at 19:03
  • seems intresting, ill take a look and get back at you. tanks a lot! Commented Aug 10, 2014 at 19:06

1 Answer 1

4

You could try this, you will need to have a key from google, the requests library and know your way with json:

geo_s ='https://maps.googleapis.com/maps/api/geocode/json'

param = {'address': address, 'key': 'YOUR_KEY'}

response = requests.get(geo_s, params=param)

json_dict = response.json()

lat = json_dict['results'][0]['geometry']['location']['lat']
lng = json_dict['results'][0]['geometry']['location']['lng']

print({'lat': lat, 'lng': lng})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.