Skip to content

Instantly share code, notes, and snippets.

@binarymatt
Last active December 24, 2015 14:39
Show Gist options
  • Select an option

  • Save binarymatt/6814187 to your computer and use it in GitHub Desktop.

Select an option

Save binarymatt/6814187 to your computer and use it in GitHub Desktop.
check for iphone 5s
import requests
parts = {
'GRAY': 'ME344LL/A',
'SILVER': 'ME345LL/A'
}
url_template = 'http://store.apple.com/us/retail/availabilitySearch?parts.0={}&zip={}'
def send_notice():
pass
def status(pickup):
if 'unavailable' in pickup:
return '[NO]'
else:
return '[YES]'
def parse_store(store):
part = store['partsAvailability'].keys()[0]
seperator = '\t\t'
if len(store['storeName']) > 16:
seperator = '\t'
print store['storeName'], seperator, status(store['partsAvailability'][part]['pickupDisplay'])
def show_availability(response_dict, count=2):
stores = response_dict['body']['stores']
map(parse_store, stores[:count])
if __name__ == "__main__":
for k, v in parts.items():
print k
print '----------------------------'
url = url_template.format(v, '37220')
response = requests.get(url)
if response.ok:
show_availability(response.json)
print ''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment