-
-
Save madmaximux/a34fdbbaff029bcd787e835aa696a0d7 to your computer and use it in GitHub Desktop.
iPhone 6 Stock Checker
This file contains hidden or 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
| import requests | |
| import datetime | |
| import time | |
| url = "https://reserve.cdn-apple.com/GB/en_GB/reserve/iPhone/availability.json" | |
| interested_stores = ['R245'] | |
| # Exclude iPhone 6 | |
| excluded = ['MGA92B/A', 'MGA92B/A', 'MGAJ2B/A', 'MGAE2B/A', 'MGAA2B/A', | |
| 'MGAK2B/A', 'MGAF2B/A', 'MGA82B/A', 'MGAH2B/A', 'MGAC2B/A'] | |
| while True: | |
| true_count = 0 | |
| dat = requests.get(url).json() | |
| last_updated = datetime.datetime.fromtimestamp(float(str(dat['updated'])[0:-3])) | |
| print last_updated | |
| for k,v in dat.items(): | |
| if k in interested_stores: | |
| for i, s in v.items(): | |
| if i not in excluded and s == True: | |
| true_count += 1 | |
| if true_count > 0: | |
| print 'iPhone 6 stock in Covent Garden!' | |
| time.sleep(5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment