1 Star 0 Fork 0

蔡培超 / autowifi

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
main.py 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
蔡培超 提交于 2014-04-24 09:12 . init
#!/usr/bin/python3
'''
Created on 2013-1-19
@author: PC
'''
# Account configuration
# Mobile phone
USERNAME = ''
# password
PASSWORD = ''
from urllib.parse import urlencode
from urllib.request import urlopen
import hashlib
import time
def main():
while True:
time.sleep(1)
try:
if not isnetworkavailable():
sendLoginRequest()
else:
print('network is available')
except Exception as ex:
print(ex)
def isnetworkavailable():
try:
url = 'http://www.baidu.com/'
response = urlopen(url, timeout=1)
html = str(response.read())
if 'Web Authentication Redirect' in html:
return False
return True
except Exception as ex:
print(ex)
return False
def sendLoginRequest():
spaceCount = 0
userName = USERNAME
password = PASSWORD
form = {'buttonClicked':'4',
'redirect_url':'',
'err_flag':'0',
'username':userName,
'password':password}
formText = bytes(urlencode(form), 'utf8')
url = 'https://wifi.zjgsu.edu.cn/login.html'
response = urlopen(url, timeout=1, data=formText)
print(md5(response.read()))
def md5(data):
return hashlib.md5(data).hexdigest()
if __name__=='__main__':
main()
Python
1
https://gitee.com/caipeichao/autowifi.git
git@gitee.com:caipeichao/autowifi.git
caipeichao
autowifi
autowifi
master

搜索帮助