Skip to content

Instantly share code, notes, and snippets.

@pkillnine
Last active May 2, 2017 17:11
Show Gist options
  • Save pkillnine/e8df4c7ef81f773b29c3a366d7335b17 to your computer and use it in GitHub Desktop.
Save pkillnine/e8df4c7ef81f773b29c3a366d7335b17 to your computer and use it in GitHub Desktop.
#!/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