Skip to content

Instantly share code, notes, and snippets.

@yumminhuang
Last active December 7, 2016 05:14
Show Gist options
  • Save yumminhuang/a9035ecb6e54651adff48b74745e432b to your computer and use it in GitHub Desktop.
Save yumminhuang/a9035ecb6e54651adff48b74745e432b to your computer and use it in GitHub Desktop.
Check whether iPhone SE is available in local Apple Stores
#! /usr/bin/env python
import requests
from tabulate import tabulate
# iPhone SE Model or any other MODEL
MODEL = 'MLYC2LL/A'
# local zipcode
ZIPCODE = '02148'
QUERY_URI = 'http://www.apple.com/shop/retail/pickup-message'
request = requests.get(QUERY_URI,
params={'parts.0': MODEL,
'location': ZIPCODE})
store_lists = request.json().get('body').get('stores')
availability = list()
for store in store_lists:
availability.append([
store.get('storeName'),
store.get('partsAvailability').get(MODEL).get('storePickEligible')
])
print(tabulate(availability, headers=['Store', 'Availability'], tablefmt='orgtbl'))
@yumminhuang
Copy link
Author

yumminhuang commented May 15, 2016

Output:

> python check_iPhone_SE.py
| Store                                  | Availability           |
|----------------------------------------+------------------------|
| Apple Store, CambridgeSide             | Unavailable for Pickup |
| Apple Store, Boylston Street           | Unavailable for Pickup |
| Apple Store, Burlington                | Unavailable for Pickup |
| Apple Store, Northshore                | Unavailable for Pickup |
| Apple Store, Chestnut Hill             | Unavailable for Pickup |
| Apple Store, South Shore               | Unavailable for Pickup |
| Apple Store, Legacy Place              | Unknown                |
| Apple Store, Natick Collection         | Unavailable for Pickup |
| Apple Store, Derby Street              | Unknown                |
| Apple Store, Rockingham Park           | Unavailable for Pickup |
| Apple Store, Pheasant Lane             | Unavailable for Pickup |
| Apple Store, Solomon Pond Mall         | Unavailable for Pickup |
| Apple Store, The Mall of New Hampshire | Unavailable for Pickup |
| Apple Store, Providence Place          | Unavailable for Pickup |
| Apple Store, Holyoke                   | Unavailable for Pickup |
| Apple Store, Evergreen Walk            | Unavailable for Pickup |
| Apple Store, Maine Mall                | Unavailable for Pickup |
| Apple Store, Westfarms                 | Unavailable for Pickup |
| Apple Store, New Haven                 | Unavailable for Pickup |
| Apple Store, Trumbull                  | Unavailable for Pickup |
| Apple Store, Crossgates                | Unavailable for Pickup |
| Apple Store, Danbury Fair Mall         | Unavailable for Pickup |
| Apple Store, Smith Haven               | Unavailable for Pickup |
| Apple Store, Stamford                  | Unavailable for Pickup |

☹️iPhone SE models are out of stock at most retail stores.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment