This example will you how to find all users connected to wifi network using Python 3. Sometimes just for fun we may want to know who all are connected to the same wifi network. We can also use the same command netsh wlan show network in cmd window to find out all users currently online in network. Here we will find all users connected to wifi network using Python programming language.

Prerequisites

Have Python installed in Windows (or Unix)
Pyhton version and Packages
Here I am using Python 3.6.6 version

Source Code

We have used command netsh wlan show network in our Python script to retrieve all online users information. The information will show you as SSID and username of all currently online users. The SSID is the name of the wifi or wireless network. It is a unique 32 alphanumeric characters for each user.

Netsh is a command-line scripting utility that allows you to display or modify the network configuration of a computer that is currently running.

WLAN commands that allow you to access the Wi-Fi profiles.

Network the unique name of wireless network.

Then we basically split, extract and format to print the wifi network name (SSID) and user name of the wifi network for currently online users.

import subprocess

results = subprocess.check_output(["netsh", "wlan", "show", "network"])
results = results.decode("ascii")
results = results.replace("\r","")
ls = results.split("\n")
ls = ls[4:]
ssids = []
x = 0
while x < len(ls):
    if x % 5 == 0:
        ssids.append(ls[x])
    x += 1
print(ssids)

Testing the application

When you run the above Python script then you will be able to see the below output in the console:

find all users connected to wifi network using python

That’s all. Hope you got idea how to find all users connected to wifi network using Python 3.

Thanks for reading.

Tags:

I am a professional Web developer, Enterprise Application developer, Software Engineer and Blogger. Connect me on JEE Tutorials | TwitterFacebook Google PlusLinkedin | Reddit

Leave a Reply

Your email address will not be published. Required fields are marked *