SEU健康申报+离校请假

SEU健康申报+离校请假

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

配置

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学习手册
记录一下,笔者后期也会慢慢学习!

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值