Skip to content

Instantly share code, notes, and snippets.

@hkamran80
Created May 14, 2018 14:38
Show Gist options
  • Save hkamran80/939c4e48b6e7ade23c413150e06a01a2 to your computer and use it in GitHub Desktop.
Save hkamran80/939c4e48b6e7ade23c413150e06a01a2 to your computer and use it in GitHub Desktop.
MAC Address Lookup
# MAC Address Lookup
from bs4 import BeautifulSoup
import requests
import sys
mac_send = []
def scan(bs_object, mac_addr):
global mac_send
loc = bs_object.find("dl", {"class":"dl-horizontal"})
company = loc.find("strong").string.strip()
mac_range = loc.find("code").string.strip()
mac_type = loc.find_all('dd')[len(loc.find_all('dd'))-1].string.strip()
mac_send = [mac_addr, company, mac_range, mac_type]
def get_bs_obj(mac_addr):
scan(BeautifulSoup(requests.get("https://macvendorlookup.com/search/" + str(mac_addr), headers={"User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:59.0) Gecko/20100101 Firefox/59.0"}).text, "html.parser"), str(mac_addr))
if __name__ == "__main__":
if len(sys.argv) == 1:
sys.exit("You must provide a MAC address when running the program! Example: python3 maclookup.py {MAC_Address}!")
else:
get_bs_obj(sys.argv[1])
print(mac_send)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment