Skip to content
Permalink
master
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
#!/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']);