Created
December 13, 2018 22:55
-
-
Save droberson/1edef35b5ae6f05e560a3c1bbd384d32 to your computer and use it in GitHub Desktop.
Get current list of OUIs from IEEE, print out a CSV.
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 python3 | |
from tempfile import mkstemp | |
from os import remove, fdopen | |
import requests | |
ouilist = requests.get("http://standards-oui.ieee.org/oui.txt") | |
tmpfd, tmpfile = mkstemp() | |
with fdopen(tmpfd, "w") as fp: | |
fp.write(ouilist.text) | |
with open(tmpfile, "r") as fp: | |
for line in fp: | |
if "(base 16)" in line: | |
split_line = line.split() | |
oui = split_line[0] | |
company_name = " ".join(split_line[3:]) | |
address1 = fp.readline().strip() | |
address2 = fp.readline().strip() | |
country = fp.readline().strip() | |
print("\"{}\",\"{}\",\"{}\",\"{}\",\"{}\"".format(oui, company_name, address1, address2, country)) | |
remove(tmpfile) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment