创作初衷:疫情期间很多高校都陆续开发出了关于学生健康打卡的模块,但是很多高校没有自己的移动便捷的软件或者学生登录网站过于繁琐和缓慢。再加上辅导员很难全面了解同学是否打卡和打卡情况。于是我做这款小软件目的是为了方便打卡和检测同学是否当天已经打卡并做出提醒。
开发简介:本软件主要采取python的 tkinter 和 selenium 中的webdrive模块等。将一些健康打卡的脚本和检测的脚本嵌入到 tkinter 中进行可视化操作,并在tkinter中加入注册和登录的初始界面,数据的写入则采取简单的记事本写入。最后将这些文件打包成一个可执行的软件。
所需工具:编辑器,Burpsuite,python环境,webdrive驱动等。
语言:python。
软件展示:
主函数
def sign_in():
Account = a_enter.get()#获取用户输入的用户名和密码
Password = b_enter.get()
Account_len = len(Account) #获取字符串
#Password_len = len(Password)
Account_1 = Account
Password_1 = Password
Account_register = ''
Password_register = ''
with open(USER,'r') as file_object:
contents = file_object.read() #对用户输入的用户名和密码进行检查
if Account_1+'JUST' in contents and Password_1+'JUST' in contents \
and contents !='' and Password_1 !='' \
and Account_1.isdigit() ==True and Account_len==12:
tip["text"] ="健康打卡!"
root.destroy() #第一个窗口关闭
global root2
root2 = Tk() #建立一个新的窗口
root2.title('健康打卡(please wait...')
#root2.resizable(0, 0) # 固定窗口
root2.attributes("-alpha", 0.8) # 登录窗口的透明化
root2.iconbitmap(".\\xxx.ico") # 登录图标设置
users_screenwidth_2 = root2.winfo_screenwidth() # 获取用户屏幕宽度
users_screenheight_2 = root2.winfo_screenheight() # 获取用户屏幕高度
canvas = Canvas(root2) #画布
canvas.pack(side='top') #定位
global photo
photo = PhotoImage(file='xxx.gif')
canvas.create_image(170, 100, image=photo)
canvas.create_window(192, 238, window=Button(root2, width=18,
activebackground='Turquoise' ,
text='一键打卡',command = lambda:Heathy_auto(Account_1,Password_1,1)))
# 窗口大小并居中
root2_width = 416
root2_height = 260
user_screen_x_2 = (users_screenwidth_2 - root2_width) / 2
user_screen_y_2 = (users_screenheight_2 - root2_height) / 2
root2.geometry("%dx%d+%d+%d" % (root2_width, root2_height,
user_screen_x_2,user_screen_y_2))
else:
tip["text"]=" 学号或密码错误!"
健康打卡的函数
def Heathy_auto(x,y,z):
url = 'http...'#高校的网址
#option = webdriver.ChromeOptions() #webdrive浏览器静默打开
#option.add_argument('headless')
driver = webdriver.Chrome(chrome_options = option) # 打开chrome浏览器
driver.get(url)
driver.find_element_by_name('username').send_keys(x)
driver.find_element_by_name('password').send_keys(y)
driver.find_element_by_class_name('login_btn').click()
if '健康信息填报' not in driver.page_source: #进一步判断用户名和密码是否错误
Heathy_auto_situation = "您的账户或密码错误"
driver.quit()
feedback(Heathy_auto_situation,z)
#sleep(3)
driver.find_element_by_class_name('boxCons').click()
driver.switch_to.window(driver.window_handles[1]) # 跳转页面
if '<div id="" class="layui-layer-content">当天已经提交过,是否继续提交?</div>' in driver.page_source:
Heathy_auto_situation = '当天您已提交!'
driver.quit()
feedback(Heathy_auto_situation,z)
elif '填报时间0:00-15:00。' in driver.page_source:
Heathy_auto_situation = '填报时间0:00-15:00。'
driver.quit()
feedback(Heathy_auto_situation,z)
else:
driver.find_element_by_xpath("//input[@name='tw']").send_keys('36.7')#输入体温等身体健康情况
driver.find_element_by_xpath("//input[@name='zwtw']").send_keys('36.6')
driver.find_element_by_id('post').click()#通过post请求提交打卡
#sleep(2)
driver.quit()
Heathy_auto_situation = '已成功打卡!'
feedback(Heathy_auto_situation,z)