Skip to content

Instantly share code, notes, and snippets.

@hoyangtsai
Last active December 3, 2017 07:52
Show Gist options
  • Save hoyangtsai/bd3016b85fc9dacc7925cf1fffcee025 to your computer and use it in GitHub Desktop.
Save hoyangtsai/bd3016b85fc9dacc7925cf1fffcee025 to your computer and use it in GitHub Desktop.
check availability of iPhoneX at Apple HK online store
const https = require('https');
const stores = [
['R409', 'Causeway'],
['R428', 'IFC_Mall'],
['R499', 'Canton_Road'],
['R485', 'Festival'],
['R673', 'A_M_P']
];
const options = {
host: 'reserve-prime.apple.com',
port: 443,
path: '/HK/zh_HK/reserve/iPhoneX/availability.json',
method: 'GET',
headers: {
'Content-Type': 'application/json',
'User-Agent': 'Mozilla/5.0'
}
};
const product = 'MQA82ZP/A';
const req = https.request(options, (res) => {
console.log(options.host + ':' + res.statusCode);
res.setEncoding('utf8');
res.on('data', (d) => {
// process.stdout.write(d);
const result = JSON.parse(d);
stores.map((store) => {
console.log(store[1], '\t', result['stores'][store[0]][product]);
})
});
}).on('error', (e) => {
console.error(e);
});
req.end();
# coding: utf-8
import requests
import time
import os
store_url = 'https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX/stores.json'
stores = [
('R409', 'Causeway'),
('R428', 'IFC_Mall'),
('R499', 'Canton_Road'),
('R485', 'Festival'),
('R673', 'A_M_P')
]
product = 'MQA82ZP/A'
availability_url = 'https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX/availability.json'
s = requests.Session()
s.headers['User-Agent'] = 'Mozilla/5.0'
i = 0
while True:
try:
availability = s.get(availability_url).json()
i += 1
for store in stores:
iphone_state = availability['stores'][store[0]][product]['availability']['unlocked']
print i, '\t', store[1], '\t', availability['stores'][store[0]][product]
if iphone_state:
os.system('say ' + store[1])
except:
print 'Not started yet.'
time.sleep(1)
IFC
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX/availability?store=R428&iUP=N&appleCare=N&rv=0&partNumber=MQA82ZP%2FA
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX?quantity=1&store=R428&partNumber=MQA82ZP%2FA&channel=&sourceID=&iUID=&iuToken=&iUP=N&appleCare=N&rv=0&path=&plan=unlocked
Causeway Bay
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX/availability?store=R409&iUP=N&appleCare=N&rv=0&partNumber=MQA82ZP%2FA
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX?quantity=1&store=R409&partNumber=MQA82ZP%2FA&channel=&sourceID=&iUID=&iuToken=&iUP=N&appleCare=N&rv=0&path=&plan=unlocked
Canton Road
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX/availability?store=R499&iUP=N&appleCare=N&rv=0&partNumber=MQA82ZP%2FA
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX?quantity=1&store=R499&partNumber=MQA82ZP%2FA&channel=&sourceID=&iUID=&iuToken=&iUP=N&appleCare=N&rv=0&path=&plan=unlocked
Festival Walk
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX/availability?store=R485&iUP=N&appleCare=N&rv=0&partNumber=MQA82ZP%2FA
AMP
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX/availability?store=R673&iUP=N&appleCare=N&rv=0&partNumber=MQA82ZP%2FA
https://reserve-prime.apple.com/HK/zh_HK/reserve/iPhoneX?quantity=1&store=R673&partNumber=MQA82ZP%2FA&channel=&sourceID=&iUID=&iuToken=&iUP=N&appleCare=N&rv=0&path=&plan=unlocked
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment