Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ALL/MACVendor.py
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
24 lines (19 sloc)
715 Bytes
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
#!/python33/python | |
#Python 3 Example how to use https://macvendors.co to lookup vendor from mac address | |
print("Content-Type: text/html\n") | |
import urllib.request as urllib2 | |
import json | |
import codecs | |
#API base url, you can also use https if you need | |
url = "http://macvendors.co/api/" | |
#Mac address to lookup vendor from | |
mac_address = input("Enter Mac Address: ") | |
request = urllib2.Request(url+mac_address, headers={'User-Agent' : "API Browser"}) | |
response = urllib2.urlopen( request ) | |
#Fix: json object must be str, not 'bytes' | |
reader = codecs.getreader("utf-8") | |
obj = json.load(reader(response)) | |
#Print company name | |
print(obj['result']['company']+"<br/>"); | |
#Print company address | |
print(obj['result']['address']); |