May-27-2019, 04:38 PM
(This post was last modified: May-27-2019, 04:38 PM by ashlynjane.)
The location I've been given to input is Indian Institute of Technology Kharagpur India, but somehow I'm getting an error with my code and hence not been able to get a final output.
Below is the code I had written, kindly let me know if I'm doing something wrong.
Regard.
----------------------------------
Below is the code I had written, kindly let me know if I'm doing something wrong.
Regard.
----------------------------------
import urllib
import json
serviceurl = "http://py4e-data.dr-chuck.net/json?"
while True:
address = 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('Retrived',len(data),'characters')
try: js = json.loads(str(data))
except: js = None
print('==== Failure To Retrieve ====')
print(data)
continue
placeid = js["results"][0]['place_id']
print("Place id",placeid)
