Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get Python to know what Wifi the user is connected to?

I'm 14, pardon my Python knowlege. I'm trying to make this program that will only run while I'm at school (on the school's Wifi) using an if/else statement like this:

if ontheschoolwifi:
     Keep running the program
else:
     close the program because im not at school and wont need it

I'd like to know how to let python know how to get what wifi it is connected to. Thank you, in advance, for your help :)

like image 957
WaydeHall Avatar asked Oct 20 '15 02:10

WaydeHall


People also ask

How do you check which devices are connected to my WiFi using python?

Who-is-on-my-wifi is a Python3 cli project that allows you to see who is stealing your WiFI network, scan your WiFI and show you how many devices are connected. Software can be installed on any Windows and Linux device (Mac not verified).

Is there a way to see what devices are connected to your WiFi?

You can check how many personal devices are connected to your Wi-Fi network in the Google Home app or the Google Wifi app.

How do I check WiFi status in python?

request def connect(host='http://google.com'): try: urllib. request. urlopen(host) #Python 3. x return True except: return False # test print( "connected" if connect() else "no internet!" )

How do you check connectivity in python?

Use the create_connection() method to establish the connection. Connect to the host and tell whether the host is actually reachable or not. Create_connection only connects to TCS sockets. If connection is established then return True otherwise return False.


1 Answers

import subprocess

if "SchoolWifiName" in subprocess.check_output("netsh wlan show interfaces"):
    print "I am on school wifi!"
like image 190
Mark Ch Avatar answered Oct 12 '22 09:10

Mark Ch