diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2019-05-11 21:38:22 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2019-05-11 21:38:22 +0530 |
commit | 6cbd67bb7232e2ed499a1b94b51d255cbaea0183 (patch) | |
tree | 12dc138f9a9cc7607e146138a08db778dcc1e98c /function-specific-programs/zomato.py | |
parent | 395ea589cc10973ceae07768e7c6484534d17c8d (diff) |
Initial Commit
Diffstat (limited to 'function-specific-programs/zomato.py')
-rw-r--r-- | function-specific-programs/zomato.py | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/function-specific-programs/zomato.py b/function-specific-programs/zomato.py new file mode 100644 index 0000000..26b4c43 --- /dev/null +++ b/function-specific-programs/zomato.py @@ -0,0 +1,41 @@ +import requests +import simplejson as sjson +import json + +res = [] + +def getRes(): + headers = { + 'Accept': 'application/json', + 'user-key': 'a530c1424d9abe5442fa22f77ce03d25', + } + + params = ( + ('lat', '28.546519'), + ('lon', '77.179248'), + ) + + response = requests.get('https://developers.zomato.com/api/v2.1/geocode', headers=headers, params=params) + res = response.json()['popularity']['nearby_res'] + return res + +def getDetails(res): + headers = { + 'Accept': 'application/json', + 'user-key': 'a530c1424d9abe5442fa22f77ce03d25', + } + url = "https://developers.zomato.com/api/v2.1/restaurant?res_id=" + str(res[0]) + newResponse = requests.get(url, headers=headers) + newRes = [] + resName = newResponse.json()['name'] + resAddress = newResponse.json()['location']['address'] + print("You are feeling sleepy, why don't you take a break?\n") + print("Your nearest eatery is " + resName,"\n") + print(resName + " is at " + resAddress,"\n") +def zomato(): + + res = getRes() + getDetails(res) +zomato() + + |