python 3.x - (ValueError: unknown url type) while opening json (python3) -


import urllib import json  serviceurl='https//maps.googleapis.com/maps/api/geocode/json?'  while true:     address=input('enter location: ')     if len(address)<1 :         break     url =serviceurl+urllib.parse.urlencode({'sensor':'false','address':address})     print('retriving',url)     uh=urllib.request.urlopen(url)     data=uh.read().decode('utf8')     print ('retrieved',len(data),'characters')     try:         js=json.loads(str(data))       except:         json=none     if 'status' not in js or js['status'] !='ok' :         print('fail~~')         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)     print(location) 

i accessing geojson api of google. "uh=urllib.request.urlopen(url)" occurs error , can't open url. problem code?

you missing : after https:

https://maps.googleapis.com/maps/api/geocode/json?  here^ 

Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -