Created
June 27, 2016 17:27
-
-
Save WardsParadox/684f480a91ea0eadc73aebe996227b77 to your computer and use it in GitHub Desktop.
Get Model Info
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
#!/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