I am calling an API to access the place id information of a location. The code is returning the JSON data with the geographical information and place ids, but the place id I am getting does not match the one I am being asked to find. The first seven characters in the place id are: "ChIJ18Y." Could someone please give me some insight on place ids? Is there a problem with my encoding statement? Thank you in advance for your inputs!
Here is what I have done so far:
import urllib
import json
serviceurl = 'http://python-data.dr-chuck.net/geojson?sensor=false&address=Madras+University'
while True:
address = raw_input('Enter location: ')
if len(address) < 1 : break
url = serviceurl + urllib.urlencode({'sensor':'false', 'address': address})
print 'Retrieving', url
uh = urllib.urlopen(url)
data = uh.read()
print 'Retrieved',len(data),'characters'
try: js = json.loads(str(data))
except: js = None
if 'status' not in js or js['status'] != 'OK':
print '==== Failure To Retrieve ===='
print data
continue
print json.dumps(js, indent=4)
lat = js["results"][0]["geometry"]["location"]["lat"]
lng = js["results"][0]["geometry"]["location"]["lng"]
print 'lat',lat,'lng',lng
location = js['results'][0]['formatted_address']
print location
python-data.dr-chuck.net/geojson (This is the API endpoint, which is a static subset of Google API data.)