易班学生安全上报系统脚本

        转眼飞逝,还没回过神来暑假就过去了一半。时间过得真快。

        今天,我又被班里同学,同学催着上报易班,淦!仔细想想,我这一个暑假被催的次数好像挺多的。然后脑子一机灵,我干脆编个脚本来上报。本来想通过易班上报的,但仔细想想,易班上报,有时候会系统崩溃(你以为我会说从易班进很麻烦吗?(骄傲,叉会腰—)),于是我直接找到上报系统的原网址:

登录 (hnsyu.net)

(账号和密码一般是学号,有些学校的密码是身份证上的后几位)

易班学生安全上报系统脚本_第1张图片

话不多说,上代码:

from selenium import webdriver
import time
def safe_declare(usename,password):
    '''输入你的用户名(usename)与密码(password)'''
    wd = webdriver.Edge(executable_path='E:\python工程\项目\selenium_llq/msedgedriver.exe')

    # 设置最大等待时长为 10秒
    wd.implicitly_wait(3)

    # 打开上报登录页
    wd.get('http://smart.hnsyu.net/xyt/home/login.do')

    # 输入账号和密码并单击登录
    wd.find_element_by_id('username1').send_keys(f'{usename}')
    wd.find_element_by_id('password1').send_keys(f'{password}')
    # 单击报平安
    wd.find_element_by_class_name('login-btn').click()
    name = wd.find_element_by_xpath('//*[@class="fixed-top bg-white ai-padding fit_768"]/div').text
    try:
        wd.find_element_by_xpath('//*[@class="bg-white w100 fn-mt10"]/button').click()
        time.sleep(0.5)
        wd.find_element_by_xpath('//*[@class="ai-padding bg-white fixed-bottom w100 fit_768"]/button').click()
        time.sleep(0.5)
        wd.find_element_by_xpath('//*[@class="weui-dialog__ft"]/a[2]').click()
        time.sleep(0.5)
        print(f'已经为{name[0:-5]}申报平安。')
    except:
        print(f'{name[0:-5]}已经申报平安!')
    return

你可能感兴趣的:(python)