简体   繁体   English

如何使用python查找并连接所有可用的wifi信号?

[英]How to find all and connect all available wifi signals using python?

I am working raspberry pi to find and connect all available wifi connections.我正在使用 raspberry pi 查找并连接所有可用的 wifi 连接。 How can I find and list all WIFI Networks available using python.如何使用 python 查找和列出所有可用的 WIFI 网络。 Can we print all available wifi connections by using python sockets.我们可以使用 python 套接字打印所有可用的 wifi 连接吗? If sockets can't do this job then which library can we use to do so?如果套接字不能完成这项工作,那么我们可以使用哪个库来做到这一点?

I think one of the best modules for wifi manipulation in python is the wifi package.我认为python中最好的wifi操作模块之一是wifi包。

pip install wifi

Simple use case is;简单的用例是; (replace "wlan0" with your wireless device id) (将“wlan0”替换为您的无线设备 ID)

from wifi import Cell, Scheme
list(Cell.all('wlan0'))

This will return a list of Cell objects.这将返回一个 Cell 对象列表。 Each object will have the following attributes:每个对象将具有以下属性:

  • ssid ssid
  • signal信号
  • quality质量
  • frequency频率
  • bitrates比特率
  • encrypted加密
  • channel渠道
  • address地址
  • mode模式

For cells that have encrypted as True, there will also be the following attributes:对于加密为 True 的单元格,还会有以下属性:

  • encryption_type加密类型

To connenc to an AP;连接到AP;

cell = list(Cell.all('wlan0'))[0]
scheme = Scheme.for_cell('wlan0', 'home', cell, passkey)
scheme.save()
scheme.activate()

scheme = Scheme.find('wlan0', 'home')
scheme.activate()

for more info goto https://wifi.readthedocs.io/en/latest/有关更多信息,请转到https://wifi.readthedocs.io/en/latest/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM