0x1 自用版(自动打卡+邮件提醒)
# 健康打卡.py
from selenium import webdriver
from selenium.webdriver.support.select import Select
import yagmail
import time
import datetime
# 只需修改下面五项即可 学号 密码 收件箱 打卡网址 第69行填写你的chrome目录
userName = '****'
password = '****'
Email = '****@qq.com'
url = "http://****.****.edu.cn/jkdk"
NewTask_XPath = "/html/body/div[2]/table/tbody[2]/tr[2]/td[2]/a"
Address_XPath = "//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[2]"
Work_Xpath = "//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[3]"
Health_XPath = "//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[4]"
Life_XPath = "//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[5]"
Family_XPath = "//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[6]"
Submit_XPath = "/html/body/form/div[1]/table/tbody/tr/td[1]/input"
nowTime = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
# 模拟登陆
def do_login(userName, password):
driver.maximize_window()
# 找到登录框 输入账号密码
driver.find_element_by_id('txtId').send_keys(userName)
driver.find_element_by_id('txtMM').send_keys(password)
# 模拟点击登录
driver.find_element_by_id('IbtnEnter').click()
time.sleep(2)
# 模拟打卡
def do_sign():
# 打开最新打卡任务
driver.find_element_by_xpath(NewTask_XPath).click()
time.sleep(2)
# 定位select框 进行选择
s1 = Select(driver.find_element_by_xpath(Address_XPath))
s2 = Select(driver.find_element_by_xpath(Work_Xpath))
s3 = Select(driver.find_element_by_xpath(Health_XPath))
s4 = Select(driver.find_element_by_xpath(Life_XPath))
s5 = Select(driver.find_element_by_xpath(Family_XPath))
s1.select_by_index(1)
s2.select_by_index(4)
s3.select_by_index(1)
s4.select_by_index(1)
s5.select_by_index(1)
time.sleep(2)
# 提交打卡
driver.find_element_by_xpath(Submit_XPath).click()
# 发送提示邮件
def sendMail(content):
yag = yagmail.SMTP("lola_39@163.com", "YKRZZPUUEVTYONJJ", "smtp.163.com")
yag.send(Email, "打卡提醒", content)
if __name__ == '__main__':
# 模拟浏览器打开网站
driver = webdriver.Chrome()
# 这里填chrome目录地址
Chromedriver = r"C:\Users\***\AppData\Local\Google\Chrome\Application"
driver.get(url)
# 登录并打卡
do_login(userName, password)
do_sign()
sendMail(nowTime + "\n打卡成功!")
print("打卡结束")
time.sleep(5)
driver.quit()
B站视频效果演示:https://www.bilibili.com/video/BV1sK411L7SR
0x2 舍友提供版(自动打卡+自动截图)
作者:FEET❤
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from PIL import ImageGrab
import time#u1s1,模块挺多 !!!!程序运行大约12秒 不用动鼠标
#点击运行后请不要动任何东西 ⊙ω⊙ ⊙ω⊙ ⊙ω⊙ ⊙ω⊙
#打开浏览器后会有几秒停顿 别慌
#此脚本包含的模块支持均为python3.8 如版本不对可能报错
#这个程序是健康打卡 非健康打卡请自重
#请仔细看注释
user="" #账号
password="" #密码
localadress="" #输入要存放截图的绝对地址(记得把地址里的“\”改成“/”)比如 C:/Users/FEET/Desktop
#超级登录
target=webdriver.Edge() #!!!!!!如果是用的谷歌浏览器就把Edge改成Chrome !记得去下载webdriver!!!!
target.maximize_window()
target.implicitly_wait(20)
def signin():
target.get("http://login.cuit.edu.cn/Login/xLogin/Login.asp")
name=target.find_element_by_id("txtId")
word=target.find_element_by_id("txtMM")
name.send_keys(user)
word.send_keys(password+Keys.ENTER)
#超级健康
def work():
latest=target.find_element_by_xpath("/html/body/div[2]/table/tbody[2]/tr[2]/td[2]/a").click()
adress=target.find_element_by_xpath("//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[2]/option[2]").click()
state=target.find_element_by_xpath("//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[3]/option[5]")
health=target.find_element_by_xpath("//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[4]/option[2]").click()
live=target.find_element_by_xpath("//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[5]/option[2]").click()
family=target.find_element_by_xpath("//*[@id='wjTA']/tbody/tr[6]/td[2]/div/select[6]/option[2]").click()
submit=target.find_element_by_name("B2").click()
target.back()
#超级截图
def screenshot():
bbox=(692,147,1249,332) #截图坐标可更改 !!!!截图完毕会自己关掉浏览器的
im=ImageGrab.grab(bbox)
im.save(localadress+'/'+'screenshot.png') #截图存放位置和名字可更改(只存放当日图片)
target.close()
if __name__ == '__main__':
signin()
try:
work()
except:
time.sleep(3)
screenshot()
Comments | NOTHING