I missed the wave of Airpods Pro. The Airpods Pro was released at the end of last month, but I thought I would buy it after looking at Sony's example Neucan and comparative reviews, but by the time I read the article, it was sold out. __It seems that the Apple Store, which is directly managed, will receive the goods from time to time __, so monitor it and send a notification __ to your __LINE as soon as the stock arrives.
Problem of how to get warehousing information Apparently it is updated properly when it arrives every morning
Click Confirm Date to receive this screen. You can get information about nearby shops by entering the zip code.
With this feeling, it seems that you can get it by GET or POST, so look at the network
There is something like this is not really this
You can see Response in the developer tools I want to make it easier to understand, so I will try to get information with an application that will GET or POST Came so much
parts is the part number and location is the zip code
The lenspons that I just returned will be returned at one store.
response
{
"head": {
"status": "200",
"data": {}
},
"body": {
"stores": [
{
"storeEmail": "[email protected]",
"storeName": "Shinsaibashi",
"reservationUrl": "http://www.apple.com/jp/retail/shinsaibashi",
"makeReservationUrl": "http://www.apple.com/jp/retail/shinsaibashi",
"state": "Osaka",
"storeImageUrl": "https://rtlimages.apple.com/cmc/dieter/store/4_3/R091.png?resize=828:*&output-format=jpg",
"country": "JP",
"city": "Osaka City",
"storeNumber": "R091",
"partsAvailability": {
"MWP22J/A": {
"storePickEligible": true,
"storeSearchEnabled": true,
"storeSelectionEnabled": true,
"storePickupQuote": "Sat 2019/12/07 Apple Shinsaibashi",
"pickupSearchQuote": "Date of receipt:<br/>Sat 2019/12/07",
"storePickupLabel": "Receipt date:",
"partNumber": "MWP22J/A",
"purchaseOption": "",
"ctoOptions": "",
"storePickupLinkText": "Check the date you can receive",
"storePickupProductTitle": "AirPods Pro",
"pickupDisplay": "ships-to-store"
}
},
"phoneNumber": "06-4963-4500",
"address": {
"address": "Apple Shinsaibashi",
"address3": "Urban BLD Shinsaibashi",
"address2": "1 Nishishinsaibashi, Chuo-ku-5-5",
"postalCode": "542-0086"
},
"hoursUrl": "http://www.apple.com/jp/retail/shinsaibashi",
"storeHours": {
"storeHoursText": "business hours",
"bopisPickupDays": "Days",
"bopisPickupHours": "time",
"hours": [
{
"storeTimings": "10:00~21:00",
"storeDays": "Month~Day:"
}
]
},
"storelatitude": 34.672,
"storelongitude": 135.50007,
"storedistance": 3.44,
"storeDistanceWithUnit": "3.44 km",
"storeDistanceVoText": "542-Distance from 0086: 3.44 km",
"storelistnumber": 1,
"storeListNumber": 1
}
----------------Continue to the bottom----------------
There seems to be no problem if you can get only __storePickupQuote
__
If you just get it, you can implement it only with requests, so write it appropriately
Acquisition of inventory information
def get_store_status(_parts, _location):
arrival = []
url = "https://www.apple.com/jp/shop/retail/pickup-message"
param = {"parts.0": _parts, "location": _location}
response = requests.get(url, params=param)
json_data = json.loads(response.text)
stores = json_data['body']['stores']
for store in stores:
store_pickup = store['partsAvailability'][_parts]['storePickupQuote']
if 'today' in store_pickup:
arrival.append({'Store':store['address']['address'],
'Postal code':store['address']['postalCode']})
return arrival
I wrote it for the time being, if I explain it appropriately Put the returned json in the dictionary The store that received the goods has today, not the date, so make such a judgment. I will pass if there is today
I don't know when the inventory information will actually be updated, so Make a request once a minute between 6:00 and 10:00.
python
def start_job():
parts = {'AirpodsPro':'MWP22J/A', 'Airpods':'MV7N2J/A'}
location = '530-0000'
end_stamp = datetime.now().timestamp() + (60 * 60 * 4)
while True:
now = datetime.now().timestamp()
arrival = get_store_status(parts['AirpodsPro'], location)
if arrival or now > end_stamp:
line_notif(arrival)
break
time.sleep(60)
def trigger():
schedule.every().day.at('06:00').do(start_job)
while True:
schedule.run_pending()
time.sleep(1)
If there is stock, you will be notified by exiting the loop If not, Oryokuru until 10 o'clock
LINE registers the Notify guy and sends it to himself Let me refer to this-Send notification to LINE with Python
python
def line_notify(stores):
line_notify_token = 'Access token'
line_notify_api = 'https://notify-api.line.me/api/notify'
if stores:
strings=''
for s in stores:
strings += f'''
Store: {s['Store']}
Postal code: {s['Postal code']}\n'''
message = f'''
Airpods Pro is in stock.
Target stores:{strings}
Shopping cart: https://www.apple.com/jp/shop/bag
'''
payload = {'message': message}
headers = {'Authorization': 'Bearer ' + line_notify_token}
requests.post(line_notify_api, data=payload, headers=headers)
If there is any arrival for the time being, this will notify LINE You can purchase it as it is by pasting the URL of the shopping cart. (It is necessary to put it in the shopping cart with the terminal and browser to purchase in advance)
I have airpods so I'll try it with this one I put the information of Airpods in the dictionary earlier, so I will use it
arrival = get_store_status(parts['Airpods'], location)
Now run.
I got a notification so it's okay
LINE Notify is very convenient, and I think it will be very useful in the future.
__ The biggest problem is whether I'm awake in the morning __
Recommended Posts