Last active
May 2, 2017 17:11
-
-
Save pkillnine/e8df4c7ef81f773b29c3a366d7335b17 to your computer and use it in GitHub Desktop.
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/env python | |
#Ale Zuvic (AirieFenix) | |
#Thanks to macvendors.com for their incredibly simple API | |
import requests | |
import sys | |
BASE_URL = 'http://api.macvendors.com' # I removed the trailing '/' as I would add that when creating the url | |
def check_vendor(mac): | |
url = "{}/{}".format(BASE_URL, mac) | |
r = requests.get(url) | |
if r.status_code == 404: | |
return None | |
elif r.status_code == 200: | |
return r.text | |
if __name__=="__main__": | |
if len(sys.argv) < 2: | |
print("Please provide a MAC.") | |
else: | |
vendor = check_vendor(sys.argv[1]) | |
if vendor: | |
print("The MAC vendor is: {}".format(vendor)) | |
else: | |
print('Vendor not found.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment