Hello,
I am learning how to create custom functions and watched the tutorial online
that uses API for locu to do cool stuff. I wanted to go little bit beyond the
tutorial and add my own features. The problem that I am running into is that I
cannot figure out how to prompt a user to input their zip code and use that
information against the function. here is my code:
import urllib2
import json
locu_api = 'not included here for obvious reasons'
zip = raw_input('What is your zip: ')
def zip_search(query):
api_key = locu_api
url = 'https://api.locu.com/v1_0/venue/search/?api_key=' + api_key
zip = query.replace(' ', '%20')
final_url = url + '&zip=' + zip + "&category=restaurant"
jason_obj = urllib2.urlopen(final_url)
data = json.load(jason_obj)
for item in data['objects']:
print item['name'], item['phone'], item['street_address'],
item['categories']
print zip_search(zip_search())
Thank you.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor