Skip to content

Instantly share code, notes, and snippets.

What would you like to do? API :: PHP GET Example
$mac_address = "FC:FB:FB:01:FA:21";
$url = "" . urlencode($mac_address);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($ch);
if($response) {
echo "Vendor: $response";
} else {
echo "Not Found";

This comment has been minimized.

Copy link

@sporkman sporkman commented Jul 20, 2017

crappy shell example:

fruitcake:~ spork$ cat

# encode from here:
rawurlencode() {
  local string="${1}"
  local strlen=${#string}
  local encoded=""
  local pos c o

  for (( pos=0 ; pos<strlen ; pos++ )); do
     case "$c" in
        [-_.~a-zA-Z0-9] ) o="${c}" ;;
        * )               printf -v o '%%%02x' "'$c"
  ENC="${encoded}"   #+or echo the result (EASIER)... or both... :p

OUI=${1:?'bad mac'}
rawurlencode $OUI
echo -n "MAC $OUI Vendor: "

This comment has been minimized.

Copy link

@ecwright3 ecwright3 commented Mar 15, 2018

import requests

macaddress = "FC-A1-3E-2A-1C-33"
r = requests.get(url="" %macaddress)


This comment has been minimized.

Copy link

@Pablohn26 Pablohn26 commented Jun 18, 2018

Now this gist get a 301 due to the use of HTTP.

To get this gist working, you have to change on line 4 http by https


This comment has been minimized.

Copy link

@ehaupt ehaupt commented Sep 26, 2020

A python solution using netaddr:

#!/usr/bin/env python

import sys
from netaddr import EUI


Accepts multiple known mac formats.

$ FC-A1-3E-2A-1C-33
Samsung Electronics Co.,Ltd
$ ./ FC:A1:3E:2A:1C:33
Samsung Electronics Co.,Ltd
$ ./ fc:a1:3e:2a:1c:33
Samsung Electronics Co.,Ltd
$ ./ fca13e2a1c33
Samsung Electronics Co.,Ltd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment