Skip to content

Instantly share code, notes, and snippets.

@WardsParadox
Created June 27, 2016 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WardsParadox/684f480a91ea0eadc73aebe996227b77 to your computer and use it in GitHub Desktop.
Save WardsParadox/684f480a91ea0eadc73aebe996227b77 to your computer and use it in GitHub Desktop.
Get Model Info
#!/usr/bin/python
'''
Gets the Model Info of your Mac from Apple's product site.
'''
from urllib2 import urlopen
from xml.dom import minidom
from sys import argv
def getmodeldesc(serial):
'''
Retrieves ConfigCode from http://support-sp.apple.com/sp/product?cc=
'''
if len(serial) > 11:
configcode = serial[-4:]
else:
configcode = serial[-3:]
try:
url = urlopen("http://support-sp.apple.com/sp/product?cc=%s " % configcode)
xml = minidom.parse(url)
code = xml.getElementsByTagName('configCode')[0].firstChild.nodeValue
except Exception as e:
code = "No Internet Connection"
return code
if __name__ == "__main__":
if len(argv) > 1:
print getmodeldesc(argv[1])
else:
print "No serial entered!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment