Skip to content

C.6 Programming Assignment 2 Code Error #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
famishedrover opened this issue May 1, 2019 · 2 comments
Open

C.6 Programming Assignment 2 Code Error #2

famishedrover opened this issue May 1, 2019 · 2 comments

Comments

@famishedrover
Copy link

Use the Key Parameter.

import urllib
import json

serviceurl = "http://py4e-data.dr-chuck.net/json?"

while True:

address = raw_input("Enter location: ")

if len(address) < 1 : break

url = serviceurl + urllib.urlencode({'sensor':'false','address':address,'key':42})

print 'Retrieving',url

uh =urllib.urlopen(url)
data = uh.read()
print 'Retrived',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

placeid = js["results"][0]['place_id']
print "Place id",placeid
@Shoaib-Siddiqui-Github
Copy link

Please provide here along with output for you code also.

@NeChow0504
Copy link

hi,
i am getting an error while executing this code
Capture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants