Skip to content

Instantly share code, notes, and snippets.

@vivekv96
Created October 6, 2020 13:45
Show Gist options
  • Save vivekv96/f11ceefa71f337ffb0f3a37f0c44f4e7 to your computer and use it in GitHub Desktop.
Save vivekv96/f11ceefa71f337ffb0f3a37f0c44f4e7 to your computer and use it in GitHub Desktop.
A simple Python script to scrape the order status information from your Apple Online Store order.
import json
import time
import requests
from bs4 import BeautifulSoup
def main():
URL = 'https://store.apple.com/xc/in/vieworder/<order-id>/<your-apple-id@gmail.com>/'
headers = {
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_16_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36'}
page = requests.get(URL, headers=headers)
soup = BeautifulSoup(page.content, 'html.parser')
json_str = soup.find_all('script', {'id': 'init_data'})[0].string
obj = json.loads(json_str)
current_status = obj['orderDetail']['orderItems']['orderItem-0000101']['orderItemStatusTracker']['d'][
'currentStatus']
print(time.strftime("%H:%M:%S", time.localtime()), current_status)
if __name__ == "__main__":
main()
@vivekv96
Copy link
Author

vivekv96 commented Oct 6, 2020

Screenshot 2020-10-06 at 7 19 19 PM

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