Last active
December 7, 2016 05:14
-
-
Save yumminhuang/a9035ecb6e54651adff48b74745e432b to your computer and use it in GitHub Desktop.
Check whether iPhone SE is available in local Apple Stores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /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')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Output: