SEU健康申报+离校请假

2023-05-16

SEU健康申报+离校请假

Github源码
通过对源码的学习修改,本程序稍作调整,将健康申报、销假和请假模块分开,目前可用。

配置

  • chromedriver下载方法,将下载的chromedriver.exe与py程序置于同一目录
  • 安装selenium模块

py程序

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from datetime import date, timedelta
import time
import random
import json
import re

chrome_options = Options()
chrome_options.add_argument('–no-sandbox')  # "–no-sandbox"参数是让Chrome在root权限下跑
chrome_options.add_argument('–disable-dev-shm-usage')
chrome_options.add_experimental_option('excludeSwitches', ['enable-automation'])
chrome_options.add_argument('--start-maximized')  # 最大化
chrome_options.add_argument('--incognito')  # 无痕隐身模式
chrome_options.add_argument("disable-cache")  # 禁用缓存
chrome_options.add_argument('log-level=3')
chrome_options.add_argument('disable-infobars')
chrome_options.add_argument('--headless')

dailyclock_url = "http://ehall.seu.edu.cn/qljfwapp2/sys/lwReportEpidemicSeu/*default/index.do#/dailyReport"
leave_url = "http://ehall.seu.edu.cn/ygfw/sys/swmxsqjappseuyangong/*default/index.do#/"


# 创建Log文件
def writeLog(text):
    with open('log.txt', 'a') as f:
        s = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()) + ' ' + text
        f.write(s + '\n')
        f.close()


# 创建账号密码文件,以后都不用重复输入
def getUserData():
    # 读取账号密码文件
    try:
        with open("loginData.json", mode='r', encoding='utf-8') as f:
            # 去掉换行符
            loginData = f.readline()
            f.close()

    # 写入账号密码文件
    except FileNotFoundError:
        print("Welcome to do THE F***ING DAILY JOB automatically in Southeast University")
        with open("loginData.json", mode='w', encoding='utf-8') as f:
            user = input('输入一卡通号: ')
            pw = input('输入密码: ')
            details = input('输入请假详情: ')
            adress = input('输入详细地址: ')
            loginData = {"username": user, "password": pw,
                         "details": details, "adress": adress, "loc": ""}
            loginData = json.dumps(loginData) + '\n'
            f.write(loginData)
            f.close()
    return loginData


# 检查是否已经超过健康申报时间
def checkTime1():
    localtime = time.localtime(time.time())
    hour = localtime.tm_hour

    if hour >= 15:  # 超过15:00则无法进行健康申报
        return True
    else:
        return False


# 检查是否已经超过明日请假时间
def checkTime2():
    localtime = time.localtime(time.time())
    hour = localtime.tm_hour

    if hour >= 16:  # 超过16:00则无法进行请假申报
        return True
    else:
        return False


# 身份认证后登录
def login(user, pw, browser):
    browser.get(leave_url)
    browser.implicitly_wait(2)

    # 填写用户名密码
    username = browser.find_element(by=By.ID, value='username')
    password = browser.find_element(by=By.ID, value='password')
    username.clear()
    password.clear()
    # send_keys()模拟按键输入 参考https://www.gaoyuanqi.cn/python-selenium-send_keys/
    username.send_keys(user)
    password.send_keys(pw)
    # 点击登录
    login_button = browser.find_element(by=By.CLASS_NAME, value='auth_login_btn')
    login_button.submit()


# 定义时间
today_year = date.today().strftime("%Y")
today_month = date.today().strftime("%m")
today_day = date.today().strftime("%d")
tomorrow_year = (date.today() + timedelta(days=1)).strftime("%Y")
tomorrow_month = (date.today() + timedelta(days=1)).strftime("%m")
tomorrow_day = (date.today() + timedelta(days=1)).strftime("%d")
tomorrow = (date.today() + timedelta(days=1)).strftime('%Y-%m-%d')


# 确认今日是否健康申报成功
def dailyDone(browser):
    browser.get(dailyclock_url)
    browser.implicitly_wait(2)
    time.sleep(1)

    date_info_raw = browser.find_element(by=By.XPATH,
                                         value="/html/body/div[1]/div/div[1]/div[3]/div/div/div[2]/div[2]/div[1]/div[2]/div/div/div[2]")
    date_info = re.findall(r"\d+\.?\d*", date_info_raw.text)
    year_info = date_info[0]
    month_info = date_info[1]
    day_info = date_info[2]

    if year_info == today_year and month_info == today_month and day_info == today_day:
        return True
    else:
        return False


# 今日健康日报
def dailyReport(browser):
    # 检查已过了健康申报时间
    if checkTime1() == True:
        print('注意:规定的今日健康申报最晚时间已过!')
        if dailyDone(browser) is True:
            print('恭喜,今日已进行过健康申报,如有问题可自行进入学校系统查看!')
        elif dailyDone(browser) is False:
            print('今日未进行健康申报!')
    else:
        print('目前是健康申报的时间段,程序即将开始运行')
        # 健康打卡
        if dailyDone(browser) is True:  # 今日已完成打卡
            print('恭喜,今日已进行过健康申报!')
            time.sleep(1)
        elif dailyDone(browser) is False:
            print('开始今日健康申报!')
            buttons = browser.find_elements_by_css_selector('button')
            for button in buttons:
                if button.get_attribute("textContent").find("新增") >= 0:
                    button.click()
                    browser.implicitly_wait(2)

                    # 输入温度36.1-36.6°之间随机值
                    inputfileds = browser.find_elements_by_tag_name('input')
                    for i in inputfileds:
                        if i.get_attribute("placeholder").find("请输入当天晨检体温") >= 0:
                            i.click()
                            i.send_keys(str(random.randint(361, 366) / 10.0))

                            # 确认并提交
                            buttons = browser.find_elements_by_tag_name('button')
                            for button in buttons:
                                if button.get_attribute("textContent").find("确认并提交") >= 0:
                                    button.click()
                                    buttons = browser.find_elements_by_tag_name('button')
                                    button = buttons[-1]

                                    # 提交
                                    if button.get_attribute("textContent").find("确定") >= 0:
                                        button.click()
                                        writeLog("今日健康申报成功")
                                        time.sleep(1)
                                        print('恭喜,今日已健康申报已完成!')
                                    else:
                                        print("WARNING: 学校可能改版,请自行进入学校系统查看")
                                    break
                            break
                    break
            browser.quit()
            print("-------------------后台已关闭----------------------")
            time.sleep(1)
            exit()

        else:
            browser.close()
            print("------------网站出现故障,请稍候重试----------------")
            print("-------------------后台已关闭-----------------------")
            time.sleep(1)


# 查看是否存在未销假记录
def checkLeaveCancel(browser):
    browser.get(leave_url)
    time.sleep(1)
    try:
        if browser.find_element(by=By.CLASS_NAME, value='mint-button'):
            return True
        else:
            return False
    except:
        return False


# 销假
def LeaveCancel(browser):
    browser.get(leave_url)
    time.sleep(1)
    browser.find_element_by_class_name('mint-button').click()  # selenium根据class定位页面元素
    time.sleep(1)
    browser.find_element_by_xpath("/html/body/div[1]/div/div/div[5]/button").click()
    time.sleep(1)
    browser.find_element_by_xpath("/html/body/div[4]/div/div[3]/button[2]").click()


# 检查明日请假是否已申请
def checkLeave(browser):
    try:
        browser.get(leave_url)
        browser.implicitly_wait(2)
        """
        implicitly_wait(): 隐式等待
        当使用了隐士等待执行测试的时候,如果 WebDriver 没有在 DOM 中找到元素,将继续等待,超出设定时间后则抛出找不到元素的异常
        一旦设置了隐式等待,则它存在整个 WebDriver 对象实例的声明周期中,隐式的等到会让一个正常响应的应用的测试变慢,它会在寻找每个元素的时候都进行等待,这样会增加整个测试执行的时间。
        """
        time.sleep(1)

        date_info2_raw = browser.find_element(by=By.XPATH, value="/html/body/div[1]/div/div/div[2]/div[1]/div[2]/div")
        date_info2 = re.findall(r"\d+\.?\d*", date_info2_raw.text)
        year_info2 = date_info2[0]
        month_info2 = date_info2[1]
        day_info2 = date_info2[2]

        if year_info2 == tomorrow_year and month_info2 == tomorrow_month and day_info2 == tomorrow_day:
            return True
        else:
            return False
    except:
        print("------------网站出现故障,请稍候重试----------------")
        return


def checkIfPassed(browser):
    time.sleep(1)
    print('正在检查明日的请假是否通过...')
    browser.get(leave_url)
    browser.implicitly_wait(2)
    time.sleep(1)
    try:
        if browser.find_element(By.XPATH, '//html/body/div[1]/div/div/div[2]/div[1]/div[1]/div[2]/div[contains(text(), "已通过")]'):
            return True
        else:
            return False
    except:
        return False


# 检查明日请假申请是否已通过
def IFF():
    if checkIfPassed(browser) == True:
        print('恭喜明日请假已通过!')
        browser.quit()
        print('-------------------后台已关闭----------------------')
        time.sleep(1)
        exit()
    else:
        print('请假暂未通过,请稍候自行进入学校系统查看!')
        browser.quit()
        print("-------------------后台已关闭----------------------")
        time.sleep(1)
        exit()


# 明日请假
def askForLeave(browser):
    if checkTime2() == True:
        print('注意!已超过16:00可能无法请假!')
    else:
        print('目前是请假的申请时间段!')

    # 检查是否已申请明日的请假
    ifAskLeave = checkLeave(browser)
    if ifAskLeave == True:
        print('已申请过明日的请假,即将检查审批是否通过...')
        IFF()
    elif ifAskLeave == False:
        print('未进行明日请假,开始请假!')
        browser.get(leave_url)
        browser.implicitly_wait(2)
        time.sleep(1)

        #####################################################################################
        # 点击申请 "+"
        js = "document.querySelector(\"#app > div > div > div.mint-fixed-button.mt-color-white.sjarvhx43.mint-fixed-button--bottom-right.mint-fixed-button--primary.mt-bg-primary\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 点击复选框 通过须知
        js = "document.querySelector(\"#CheckCns\").click();"
        browser.execute_script(js)
        time.sleep(1)

        js = "document.querySelector(\"body > div.mint-msgbox-wrapper > div > div.mint-msgbox-btns > button.mint-msgbox-btn.mint-msgbox-confirm.mt-btn-primary\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 请假类型
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(2) > div > a > span\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 选择因事出校(当天往返)
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(2) > div > div > div.mint-box-group > div > div > div > a:nth-child(1) > div.mint-cell-wrapper.mt-bColor-grey-lv5.mint-cell-no-bottom-line > div.mint-cell-title > label > span.mint-radiobox > span\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 请假属性
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(3) > div > a > span\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 选择因公
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(3) > div > div > div.mint-box-group > div > div > div > a:nth-child(2) > div.mint-cell-wrapper.mt-bColor-grey-lv5.mint-cell-no-bottom-line > div.mint-cell-title > label > span.mint-radiobox > span\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 因公类型
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(5) > div > a > span\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 选择实验
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(5) > div > div > div.mint-box-group > div > div > div > a:nth-child(3) > div.mint-cell-wrapper.mt-bColor-grey-lv5.mint-cell-no-bottom-line > div.mint-cell-title > label > span.mint-radiobox > span\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 通行开始时间
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(6) > div > a \").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定年份
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(6) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(1) > ul > li:nth-child(" + str(
            int(tomorrow_year) - 1921) + ")\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定月份
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(6) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(2) > ul > li:nth-child(" + tomorrow_month + ")\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定日期
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(6) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(3) > ul > li:nth-child(" + tomorrow_day + ")\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定小时 0
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(6) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(4) > ul > li:nth-child(1)\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定分钟 16
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(6) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(5) > ul > li:nth-child(17)\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 最后点确认
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(6) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__toolbar.mt-bColor-grey-lv6 > div.mint-picker__confirm.mt-color-theme\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 通行结束时间
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(7) > div > a\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定年份
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(7) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(1) > ul > li:nth-child(" + str(
            int(tomorrow_year) - 1921) + ")\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定月份
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(7) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(2) > ul > li:nth-child(" + tomorrow_month + ")\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定日期
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(7) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(3) > ul > li:nth-child(" + tomorrow_day + ")\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定小时 23
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(7) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(4) > ul > li:nth-child(24)\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定分钟 52
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(7) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__columns > div:nth-child(5) > ul > li:nth-child(53)\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 最后点确认
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(7) > div > div.mint-popup.mt-bg-white.mint-datetime.emapm-date-picker.mint-popup-bottom > div > div.mint-picker__toolbar.mt-bColor-grey-lv6 > div.mint-picker__confirm.mt-color-theme\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 请假详情
        input_box = browser.find_element(by=By.XPATH,
                                         value="/html/body/div[1]/div/div/div/div[1]/div[2]/div/div[2]/div[9]/div/a/div[2]/div[2]/div[1]/textarea")
        try:
            input_box.send_keys(details)
            print('正在填写请假详情...')
        except Exception as e:
            print('fail')
        time.sleep(1)

        #####################################################################################
        # 活动校区
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(12) > div > a > span \").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 选择九龙湖校区
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(12) > div > div > div.mint-box-group > div > div > div > a:nth-child(1) > div.mint-cell-wrapper.mt-bColor-grey-lv5.mint-cell-no-bottom-line > div.mint-cell-title > div > label > span.mint-checkbox-new\").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 确定
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(12) > div > div > div.mint-selected-footer.__emapm > div.mint-selected-footer-bar > button.mint-button.mint-selected-footer-confirm.mt-btn-primary.mint-button--large\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 是否离开南京
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(13) > div > a \").click();"
        browser.execute_script(js)
        time.sleep(1)

        # 选择否
        js = "document.querySelector(\"#app > div > div > div > div.emapm-form > div:nth-child(2) > div > div.mint-cell-group-content.mint-hairline--top-bottom.mt-bg-white.mt-bColor-after-grey-lv5 > div:nth-child(13) > div > div > div.mint-box-group > div > div > div > a:nth-child(2) > div.mint-cell-wrapper.mt-bColor-grey-lv5.mint-cell-no-bottom-line > div.mint-cell-title > label\").click();"
        browser.execute_script(js)
        time.sleep(1)

        #####################################################################################
        # 地址
        input_box = browser.find_element(by=By.XPATH,
                                         value="/html/body/div[1]/div/div/div/div[1]/div[2]/div/div[2]/div[21]/div/a/div[2]/div[2]/input")
        try:
            input_box.send_keys(adress)
        except Exception as e:
            print('申请失败!')
        time.sleep(1)

        #####################################################################################
        # 提交
        js = "document.querySelector(\"#app > div > div > div > div.mint-layout-container.sjakudbpe.OPjb4dozyy > button\").click();"
        browser.execute_script(js)
        time.sleep(1)
        writeLog("明日请假申报成功")
        print("已完成明日请假!")
        IFF()  # 检查是否通过
    else:
        browser.close()
        print("------------网站出现故障,后台已关闭----------------")
        time.sleep(1)


if __name__ == "__main__":
    userData = getUserData()
    loginData = json.loads(str(userData).strip())
    user = loginData['username']
    pw = loginData['password']
    details = loginData['details']
    adress = loginData['adress']
    browser_loc = loginData['loc']

    # 判断是否写入非默认安装位置的 Chrome 位置
    if len(browser_loc) > 10:
        chrome_options.binary_location = browser_loc
    print("Welcome to this Program which can Automatically Do THE F***ING DAILY JOB of Southeast University")
    S = str(input("进行健康申报,请输入'Y'继续;销除请假记录,请输入'X'继续;进行明日请假,请输入'Z'继续;输入'N'退出本次操作: "))
    try:
        if S == "N":
            print('本次运行结束,本窗口将在1秒后自动关闭,再见!')
            time.sleep(1)
            exit(0)
        elif S == "Y":
            service = Service("chromedriver.exe")
            browser = webdriver.Chrome(service=service)
            print("------------------已启动,后台运行中----------------------")
            login(user, pw, browser)
            browser.implicitly_wait(2)
            dailyReport(browser)
            browser.quit()
            print("-------------------后台已关闭----------------------")
            time.sleep(1)
            exit()
        elif S == "X":
            service = Service("chromedriver.exe")
            browser = webdriver.Chrome(service=service)
            print("------------------已启动,后台运行中----------------------")
            login(user, pw, browser)
            browser.implicitly_wait(2)
            while checkLeaveCancel(browser) == True:
                print('有未销假记录,正在销假...')
                LeaveCancel(browser)
                time.sleep(1)
            print("已申请销假,销假可能需学校人工审核!")
            browser.close()
            print("-----------------------后台已关闭-------------------------")
            time.sleep(10)
        elif S == "Z":
            service = Service("chromedriver.exe")
            browser = webdriver.Chrome(service=service)
            print("------------------已启动,后台运行中----------------------")
            login(user, pw, browser)
            browser.implicitly_wait(2)
            askForLeave(browser)
            browser.quit()
            print("-------------------后台已关闭----------------------")
            time.sleep(1)
            exit()
    except:
        browser.quit()
        print("------------网站出现故障,请稍候重试----------------")
        print("-------------------后台已关闭-----------------------")
        time.sleep(1)
        exit()

后记

selenium学习手册
记录一下,笔者后期也会慢慢学习!

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SEU健康申报+离校请假 的相关文章

随机推荐

  • 关于postman的请求参数的格式问题

    版权声明 xff1a 创作不易 xff0c 转载请附上本文地址https blog csdn net weixin 40375601 article details 85121974 注意点 xff1a 1 GET请求 2 参数格式为par
  • Specification中一个条件用或者表示(criteriaBuilder.or)

    Specification spec 61 root criteriaQuery criteriaBuilder gt List lt Predicate gt predicate 61 new ArrayList lt gt Predic
  • 在高德地图使用: AMap is not defined

    高德模板原版引入 xff1a lt script language 61 34 javascript 34 src 61 34 webapi amap com maps v 61 1 4 15 amp key 61 43b2dae85b7a
  • lottie动画使用

    1 安装 span class token function npm span i span class token parameter variable save span vue lottie 2 main js 中引入 span cl
  • Kotlin 开发Android app(十):Android控件绑定ViewBinding

    上一节中 xff0c 我们知道了Android的布局 xff0c 这种把界面和逻辑控制分开 xff0c 是编程里很好的分离方式 xff0c 也大大的解耦了界面和逻辑控制 xff0c 使得编程的逻辑不在和界面挂钩 有了界面的布局 xff0c
  • 在GitHub中绑定自己的域名,并实现https访问

    购买域名 由于项目的需要 xff0c 需要建一个网站来展现一些工具的信息 xff0c 就准备购买一个域名来放置自己的工具 购买域名比较简单我们先放着 xff0c 一个重要的问题是买哪个域名 选择一个好的域名是非常重要的 以下是一些选择好域名
  • 【hive】基于Qt5和libuv udp 的lan chat

    作者已经不更新了 但是很棒 在线用户列表 聊天窗口 主程序 单独的网络线程 network thread data管理关联网络管理的 程序update升级更新 和消息收到 即可
  • 两则预防crontab重复执行任务策略

    案例分析 前台异步上传文件到云端后台cron 10 usr local bin php path to upload php gt gt tmp apkqueue log 有时候上传一个文件到云端会很耗时 xff0c 一个cron还没有跑完
  • Windows10 Server 2012 2016 2019系统自动登录设置

    本教程适用于Windows Server 2008 2012 2016 2019服务器操作系统 Windows10的 xff1a 1909 1903 1809 1803及以下的版本 Windows电脑设置空密码风险很大 xff0c 设置了密
  • HAL库+环形队列(CFIFO)+Usart1+DMA数据缓存收发

    目录 一 参考文档 二 源代码 三 结构说明 四 原理讲解 五 代码讲解 4 1循环队列 CFIFO 代码 4 1 1 xff1a cifio h 4 1 1 xff1a cifio c 4 2循环队列 CFIFO 43 DMA实现USAR
  • linux登陆远程服务器的方式

    1 使用ssh设置好之后远程登录 xff1b 2 使用linux命令远程登录 xff1a 在macOS中 Linux系统同样适用 xff0c 打开终端 xff0c 输入ssh username 64 host就可以登录远程主机了 这里use
  • (计算机组成原理)Cache和主存之间的映射方式

    地址映射变换机构是将CPU送来的主存地址转换为Cache地址 由于贮存和Cache的块大小相同 xff0c 块内地址都是相对于快的起始地址的偏移量 xff08 即低位地址相同 xff09 xff0c 因此地址变换主要是主存块号与Cache块
  • 对于典型数据集,不同神经网络分类器的精确度排序

    不同神经网络分类器的精确度排序 包括如下典型数据集 xff1a MNIST CIFAR 10 CIFAR 100 STL 10 SVHN the website of the current state of the art in obje
  • CCF 202012-2 期末预测之最佳阈值 python

    CCF 202012 2 期末预测之最佳阈值 python 100 这道题对时间进行了限制 xff0c 所以要想一次遍历得出结果 xff0c 就应该思考 xff01 样例输入 安全指数011357挂科情况001111 思路详解 lt 前提
  • failed to open X11 display

    kali xff1a failed to open X11 display 在使用kali的rdeshtop进行远程桌面时 xff0c 出现了如下错误 xff1a root 64 kali span class token comment
  • python plt 画图实战

    matplotlib pyplot 画图实战 如果你想将神经网络的训练结果 xff0c 清晰地呈现出来 xff0c 不妨看看这篇文章 xff01 技术要点 xff1a 1 一张figure呈现一个横坐标对应多个纵坐标的曲线图 2 设置标题
  • 模拟退火解决TSP问题

    模拟退火解决TSP问题 模拟退火 https mp weixin qq com s src 61 11 amp timestamp 61 1633564978 amp ver 61 3359 amp signature 61 oeLMbNZ
  • Neo4j 下载安装

    Neo4j 下载安装 Windows Neo4j community 新旧版本下载 旧版本在官网上已经找不到了 xff0c 新旧版本的区别在于登录是否需要密码 Windows Neo4j community 2 0 1及2 1 0 不需要密
  • 【libuv】1.44 windows构建

    uv a 作为一个独立的工程构建的 c 工程里c符号找不到 链接不过 Build started span class token punctuation span span class token operator span class
  • SEU健康申报+离校请假

    SEU健康申报 43 离校请假 Github源码 通过对源码的学习修改 xff0c 本程序稍作调整 xff0c 将健康申报 销假和请假模块分开 xff0c 目前可用 配置 chromedriver下载方法 xff0c 将下载的chromed