Advertisement
Guest User

Untitled

a guest
May 27th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. import requests, json, time
  2.  
  3.  
  4. zipcode = {'zipcode':'94530'}
  5. #API_URL = "https://munchery.com/menus.json?page="+str(PAGE)+"&zipcode="+str(ZIPCODE)
  6. #CHECK_URL = "https://api.spoonrocket.com/userapi/menu.json?lat=37.77340877788322&lng=-122.42621837183833"
  7. def get_menu_json():
  8. return json.loads(requests.get("https://munchery.com/menus.json?page=1", params = zipcode).text)['menu']
  9.  
  10.  
  11. def get_necessary_information(menu):
  12. output_menu = []
  13. for item in menu:
  14. output_item = {}
  15. output_item['name'] = item['name']
  16.  
  17. output_menu.append(output_item)
  18. return output_menu
  19.  
  20.  
  21. def save_information_to_json(path, information):
  22. print "information saved as" + path
  23. with open(path,'w') as outfile:
  24. json.dump(information, outfile, indent = 4)
  25.  
  26. if __name__ == "__main__":
  27. menu_json = get_menu_json()
  28. menu_json = get_necessary_information(menu_json)
  29. save_information_to_json('muncheryz.json', menu_json)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement