Skip to content

Instantly share code, notes, and snippets.

@sdushantha
Last active September 23, 2020 08:37
Show Gist options
  • Save sdushantha/4b5b51380568e03cf4d05b1124c6428d to your computer and use it in GitHub Desktop.
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
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