WiGLE is a popular platform which can be used for finding the location of a device using the names of WiFi networks in its vicinity. I’ve written about this before, and wrote some Python code to interact with their API. This API has since been retired and replaced with a new one, as of December […]
I came across a service called Wigle recently and since so many of you who come here are interested in geolocation tools and software I thought I’d pass this little Python code snippet along.
It takes WiFi MAC addresses and looks up the latitude and longitude from a collection of 100,000,000 known networks that have been submitted. It’s essentially an open version of what Google Maps do to improve the accuracy of your GPS on Android.
You can use it to look up your own MAC address, or you can pass in a MAC address you want to locate.
def __init__(self, username, password):
def get_lat_lng(self, mac_address=None):
if mac_address == None:
mac_address = self.mac_address
if '-' in mac_address:
mac_address = mac_address.replace('-', ':')
self.query_response = self.send_query(mac_address)
response = self.parse_response()
response = 'MAC location not known'
def agent(self, username, password):
self.agent = requests.Session()
mac = hex(getnode())
mac_bytes = [mac[x:x+2] for x in xrange(0, len(mac), 2)]
self.mac_address = ':'.join(mac_bytes[1:6])
def send_query(self, mac_address):
response = self.agent.post(url='https://wigle.net/gps/gps/main/confirmlocquery',
lat = self.get_lat()
lng = self.get_lng()
return lat, lng
resp_lat = re.findall(r'maplat=.*\&', self.query_response)
lat = resp_lat.split('&').split('=')
resp_lng = re.findall(r'maplon=.*\&', self.query_response)
lng = resp_lng.split('&').split('=')
To use it you need to sign up with wigle.net, and make a note of your username and password.
Then to set up the agent call:
mac_locater = WigleAgent(
To look up the system MAC address use:
And if you want to look up a specific MAC address use:
Let me know in the comments if you’d like to see an Excel VBA version of this.