Created
October 18, 2013 08:45
-
-
Save franquis/7038535 to your computer and use it in GitHub Desktop.
Parsing IEEE OUI with Python
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 | |
# -*- coding: UTF-8 -*- | |
import urllib2, re | |
def ParseIEEEOui(url = "http://standards.ieee.org/develop/regauth/oui/oui.txt"): | |
req = urllib2.Request(url) | |
res = urllib2.urlopen(req) | |
data = res.read() | |
IEEOUI = [] | |
for line in data.split('\n'): | |
try: | |
mac, company = re.search(r'([0-9A-F]{2}-[0-9A-F]{2}-[0-9A-F]{2})\s+\(hex\)\s+(.+)', line).groups() | |
IEEOUI.append(dict(mac=mac, company=company)) | |
except AttributeError: | |
continue | |
return IEEOUI |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment