代码拉取完成,页面将自动刷新
#!/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()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。