Created
October 6, 2020 13:45
-
-
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.
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
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() |
Author
vivekv96
commented
Oct 6, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment