有了python,我再也不用自己手動Eswis健康打卡啦!

天天要手動健康打卡,對於偶爾會忘掉的我來說(我連上下班打卡都會忘),真的好難受。
於是想着,用python實現自動化就好了哈哈。
話不多說,上代碼

import schedule
import time
from selenium import webdriver

account = ["123456", "654321"]
password = ["123456", "654321"]
place = ["廣東省廣州市南沙區", "廣東省廣州市白雲區"]


def job():
    for i in range(len(account)):
        driver = webdriver.Chrome(r"C:\Users\Administrator\PycharmProjects\untitled\venv\Lib\site-packages\selenium\webdriver\chrome\chromedriver.exe")  # 調用谷歌瀏覽器驅動
        driver.maximize_window()  # 最大化窗口
        driver.get("http://eswis.gdpu.edu.cn/Default.aspx")  # 打開學校網頁
        driver.find_element_by_css_selector("span#ctl00_gologin>a").click()
        driver.find_element_by_css_selector("input#log_username").send_keys(account[i])  # 賬號
        driver.find_element_by_css_selector("input#log_password").send_keys(password[i])  # 密碼
        driver.find_element_by_css_selector("a#logon").click()
        driver.find_element_by_xpath("//li[@class='bdpink bg_grant ']/a").click()
        driver.find_element_by_css_selector("ul#ctl00_cph_right_myapps>li>a").click()
        driver.find_element_by_css_selector("input#ctl00_cph_right_ok_submit").click()
        driver.find_element_by_css_selector("input#ctl00_cph_right_e_atschool_1").click()
        driver.find_element_by_css_selector("input#ctl00_cph_right_e_location").send_keys(place[i])  # 所在地區
        driver.find_element_by_css_selector("input#ctl00_cph_right_e_observation_0").click()
        driver.find_element_by_css_selector("input#ctl00_cph_right_e_health_0").click()
        driver.find_element_by_css_selector("input#ctl00_cph_right_e_temp").send_keys('36.8')
        driver.find_element_by_css_selector("input#ctl00_cph_right_e_submit").click()


schedule.every().day.at("07:00").do(job)

while True:
    schedule.run_pending()
    time.sleep(1)

以上便是全部代碼啦~
這樣我和我女朋友就再也不用鬧鐘打卡了~
後續想試試拿statuscode,然後用測試號發個微信打卡成功消息模板,就是可惜測試號只能五個成員~


因爲我使用了selenium,如果遇到了什麼問題,可以看看我這兩篇文章~
pycharm中導入selenium
selenium.common.exceptions.WebDriverException: Message: chromedriverexecut

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章