創作初衷:疫情期間很多高校都陸續開發出了關于學生健康打卡的模塊,但是很多高校沒有自己的移動便捷的軟體或者學生登錄網站過于繁瑣和緩慢,再加上輔導員很難全面了解同學是否打卡和打卡情況,于是我做這款小軟體目的是為了方便打卡和檢測同學是否當天已經打卡并做出提醒,
開發簡介:本軟體主要采取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)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/226143.html
標籤:AI
