如何使用python查找并连接所有可用的wifi信号? [英] How to find all and connect all available wifi signals using python?

查看:336
本文介绍了如何使用python查找并连接所有可用的wifi信号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 raspberry pi 查找并连接所有可用的 wifi 连接.如何使用 python 查找和列出所有可用的 WIFI 网络.我们可以使用 python 套接字打印所有可用的 wifi 连接吗?如果套接字不能完成这项工作,那么我们可以使用哪个库来完成这项工作?

I am working raspberry pi to find and connect all available wifi connections. How can I find and list all WIFI Networks available using python. Can we print all available wifi connections by using python sockets. If sockets can't do this job then which library can we use to do so?

推荐答案

我认为 python 中最好的 wifi 操作模块之一是 wifi 包.

I think one of the best modules for wifi manipulation in python is the wifi package.

pip 安装wifi

简单的用例是;(将wlan0"替换为您的无线设备 ID)

Simple use case is; (replace "wlan0" with your wireless device id)

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

这将返回一个 Cell 对象列表.每个对象将具有以下属性:

This will return a list of Cell objects. Each object will have the following attributes:

  • ssid
  • 信号
  • 质量
  • 频率
  • 比特率
  • 加密
  • 频道
  • 地址
  • 模式

对于加密为 True 的单元格,还会有以下属性:

For cells that have encrypted as True, there will also be the following attributes:

  • 加密类型

连接到一个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()

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

for more info goto https://wifi.readthedocs.io/en/latest/

这篇关于如何使用python查找并连接所有可用的wifi信号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆