Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • webscraping
  • Beautiful Soup
  • Selenium
  • Scrapy
  • urllib
  • open cv
  • Data analysis
  • Machine learning
  • NLP
  • Deep learning
  • Data Science
  • Interview question
  • ML math
  • ML Projects
  • ML interview
  • DL interview
Open In App
Next Article:
Python script to get device vendor name from MAC Address
Next article icon

Python script to get device vendor name from MAC Address

Last Updated : 07 Sep, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Prerequisite: Python Requests

A MAC address is a unique identity of a network interface that is used to address the device in a Computer Network.

What does MAC Address consist of?

A MAC address is made up of 12 hexadecimal digits, 6 octets separated by ':'. There are 6 octets in a MAC address. In the first half, the manufacturer info is stored.

MAC-Address

How do we get the Manufacturer details?

For this article, we will be using an API that will fetch the MAC Address for us. We will use a Python script to automate the fetching process so that we can use it later in the Softwares and websites that may require this functionality.

We will use requests module to work with this API.

Below is the implementation.

Python3
import requests import argparse  print("[*] Welcome")  # Function to get the interface name def get_arguments():        # This will give user a neat CLI     parser = argparse.ArgumentParser()          # We need the MAC address     parser.add_argument("-m", "--macaddress",                         dest="mac_address",                         help="MAC Address of the device. "                         )     options = parser.parse_args()          # Check if address was given     if options.mac_address:         return options.mac_address     else:         parser.error("[!] Invalid Syntax. "                      "Use --help for more details.")   def get_mac_details(mac_address):          # We will use an API to get the vendor details     url = "https://api.macvendors.com/"          # Use get method to fetch details     response = requests.get(url+mac_address)     if response.status_code != 200:         raise Exception("[!] Invalid MAC Address!")     return response.content.decode()  # Driver Code if __name__ == "__main__":     mac_address = get_arguments()     print("[+] Checking Details...")          try:         vendor_name = get_mac_details(mac_address)         print("[+] Device vendor is "+vendor_name)     except:                # Incase something goes wrong         print("[!] An error occurred. Check "               "your Internet connection.") 

Save this code as macdetails.py. We can use '-h' or '--help' to see the help on how to run this script from the terminal.

Output : 


Next Article
Python script to get device vendor name from MAC Address

M

mukulbindal170299
Improve
Article Tags :
  • Python
  • python-utility
  • Python-requests
  • Python-projects
  • Python web-scraping-exercises
Practice Tags :
  • python

Similar Reads

    How to get value from address in Python ?
    In this article, we will discuss how to get the value from the address in Python. First, we have to calculate the memory address of the variable or python object which can be done by using the id() function. Syntax: id(python_object) where, python_object is any python variable or data structure like
    4 min read
    Python - tensorflow.DeviceSpec.parse_from_string()
    TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks. parse_from_string() is used to parse a DeviceSpec name into its components.  Syntax: tensorflow.DeviceSpec.parse_from_string( spec ) Parameters: spec: It is a string of
    1 min read
    Python - tensorflow.DeviceSpec.from_string()
    TensorFlow is open-source Python library designed by Google to develop Machine Learning models and deep learning  neural networks.  from_string is used to generate DeviceSpec from string. Syntax: tensorflow.DeviceSpec.from_string( spec ) Parameters: spec: It is a string of the form  /job:/replica:/t
    1 min read
    Extracting MAC address using Python
    MAC address also known as physical address is the unique identifier that is assigned to the NIC (Network Interface Card) of the computer. NIC helps in connection of a computer with other computers in the network. MAC address is unique for all the NIC's. Uses of MAC address : Useful in places where I
    3 min read
    How to Disconnect Devices from Wi-Fi using Scapy in Python?
    Without permission, disconnecting a device from a Wi-Fi network is against the law and immoral. Sometimes, you might need to check your network's security or address network problems. You may send a de-authentication packet to disconnect devices from Wi-Fi using Scapy, a potent Python packet manipul
    5 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences