python 自动重连wifi windows
来源:互联网 发布:投针法计算圆周率c语言 编辑:程序博客网 时间:2024/05/16 14:39
# coding=utf-8import urllib2import urllibfrom cookielib import CookieJarimport osimport reimport timeclass ConnectWeb(object): def __init__(self): self.cookiejarinmemory = CookieJar() self.opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(self.cookiejarinmemory)) urllib2.install_opener(self.opener) self.username = "" self.password = "" def connect_baidu(self): #检测目前是否联网 try: urllib2.urlopen("http://www.baidu.com", timeout=2) return 1 except: return 0 def login(self): #模拟上网验证 验证网页几乎都是不同的,下面附上我们学校的, form表单自己根据情况填,用chrome很容易得到post的url和表单 try: post_url = "" form = {"action": "login", "username": self.username, "password": self.password, "ac_id": 4, "user_ip": "", "nas_ip": "", "user_mac": "", "save_me": 1, "ajax": 1} fm1 = urllib.urlencode(form) page = urllib2.urlopen(post_url, fm1).read() except Exception as e: self.disconnect() time.sleep(1) self.connect_wifi() def disconnect(self):# 断开wifi os.system("netsh wlan disconnect") def wifis_nearby(self):# 查询附近wifi p = os.popen("netsh wlan show all") content = p.read().decode("GB2312", "ignore") temp = re.findall(u"(SSID.*\n.*Network type.*\n.*\u8eab\u4efd\u9a8c\u8bc1.*\n.*\u52a0\u5bc6.*\n.*BSSID.*\n)", content) result = [] for i in temp: name = re.findall(u"SSID.*:(.*)\n", i)[0].replace(" ", "") result.append(name) return result def connect_wifi(self, name=None): #连接wifi os.system("netsh wlan connect name=%s" % name) def checking(self):# 一直检测是否有断网,如果断网则重新连接 while 1: try: if not self.connect_baidu(): self.login() except: pass time.sleep(10)if __name__ == "__main__": test = ConnectWeb() test.login()
0 0
- python 自动重连wifi windows
- 【转载】Python实现树莓派WiFi断线自动重连
- Wifi断网自动重连
- Python 实现断网自动重连
- Python 实现断网自动重连
- Python之Socket自动重连
- 树莓派WiFi重连
- Wifi断网自动重连(二)
- androidM wifi重连分析
- 自动重连
- asmack自动重连
- mysql 自动重连
- 数据库自动重连
- TCP自动重连
- python爬虫——校园网自动重连脚本
- Python--校园网开机登陆+断网检测+自动重连
- Android 如何修改wifi连接失败后自动重连次数?
- Android 如何修改wifi连接失败后自动重连次数?
- 实现简单的代码热替换
- 用JS获取地址栏参数的方法(超级简单)
- 选票统计
- 史上最全最强SpringMVC详细示例实战教程
- 发现了一个非常好用的 免费 仿真终端 MobaXterm 感觉比 SecureCRT 好用
- python 自动重连wifi windows
- Spring基础
- js实现冒泡排序
- win7 32位系统下安装paddle
- .gitignore简介
- bzoj1600(排列组合)
- 接口--制作接口
- BackgroundWriterMain代码
- Microsoft SQL Server,错误2