Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using the GeoJSON API
#1
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.
----------------------------------
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)
Reply


Messages In This Thread
Using the GeoJSON API - by ashlynjane - May-27-2019, 04:38 PM
RE: Using the GeoJSON API - by heiner55 - May-27-2019, 04:54 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  geojson to json --missing multiple row output yoshi 9 2,844 Mar-06-2022, 08:34 PM
Last Post: snippsat
  [geoJSON] View + work with? Winfried 2 2,699 Aug-25-2018, 11:14 AM
Last Post: Winfried
  formatting string and returning as geojson garynobles 12 6,699 Mar-06-2018, 05:02 PM
Last Post: garynobles

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020