Last active
September 23, 2020 08:37
-
-
Save sdushantha/4b5b51380568e03cf4d05b1124c6428d to your computer and use it in GitHub Desktop.
Get the basic device specs based on serial number for Apple Devices. Useful to check inventory
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 sys | |
# Can be 'computer' or 'tablet' | |
deviceType = "computer" | |
serialNumber = input("Serial: ") | |
print() | |
data = { | |
'cat': 'computer', | |
'bid': '1', | |
'sno': serialNumber | |
} | |
s = requests.Session() | |
r = s.post('https://www.apple.com/shop/tradein-verify?bfr=false', data=data) | |
try: | |
try: | |
r.json().get("body").get("errors")[0].get("message") | |
print("The serial number is invalid") | |
sys.exit() | |
except TypeError: | |
PID = r.json().get("body").get("parameters").get("pid") | |
except AttributeError: | |
print("Error: was not able to get data") | |
print("========RAW DATA========") | |
print(r.json()) | |
sys.exit() | |
r = s.get(f"https://www.apple.com/shop/tradein-module?cat=computer&bid=1&pid={PID}&module=verify") | |
print(r.json().get("body").get("moduleData").get("moreInfo")) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment