Skip to content

Instantly share code, notes, and snippets.

@matiskay
Created September 6, 2014 23:23
Show Gist options
  • Save matiskay/6db9f9d46bd306f64811 to your computer and use it in GitHub Desktop.
Save matiskay/6db9f9d46bd306f64811 to your computer and use it in GitHub Desktop.
Get Pizza information
import requests
import json
pizza_list = 'http://pizzahut.com.pe/Content/static/jsons/pizza-list.json'
#size_list = 'http://pizzahut.com.pe/Content/static/jsons/size-list.json'
r = requests.get(pizza_list)
pizzas = json.loads(r.text)
header = '''
______ __ _______ __
| __ \__|.-----.-----.---.-. | | |.--.--.| |_
| __/ ||-- __|-- __| _ | | || | || _|
|___| |__||_____|_____|___._| |___|___||_____||____|
'''
print header
for i, pizza in enumerate(pizzas):
name = pizza.get('name', '')
name = name.capitalize()
description = pizza.get('description', '')
print '%d.- %s: %s' % (i + 1, name, description)
prices = pizza.get('prices', [])
for j, price in enumerate(prices):
if j == 0:
type = 'Pan pizza - Familiar'
elif j == 1:
type = 'Pan pizza - Duo familiar'
elif j == 2:
type = 'Tradicional - Mediana'
elif j == 3:
type = 'Tradicional - Grande'
elif j == 4:
type = 'Tradicional - Familiar'
elif j == 5:
type = 'Tradicional - Duo familiar'
elif j == 6:
type = 'Hut cheese - Familiar'
print ' %s S./ %s' % (type, price)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment