国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python 自動重連wifi windows的方法

2020-02-16 00:11:33
字體:
來源:轉載
供稿:網友

如下所示:

# 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()

以上這篇python 自動重連wifi windows的方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持武林站長站。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 南郑县| 中方县| 睢宁县| 宣城市| 高州市| 阿城市| 呼和浩特市| 玉龙| 毕节市| 沾化县| 双柏县| 闽侯县| 桐乡市| 南江县| 凤山市| 杭锦后旗| 安泽县| 雷州市| 永康市| 岳普湖县| 仪陇县| 宜黄县| 周至县| 兴化市| 元谋县| 越西县| 津市市| 宁强县| 枞阳县| 镇雄县| 高碑店市| 邓州市| 永川市| 榆社县| 邮箱| 武山县| 四会市| 疏勒县| 屏南县| 武宣县| 泸定县|