"""
Date:2021.08.04
By Chris
"""
import time
from selenium import webdriver
import smtplib
from email.mime.text import MIMEText
params = {
"latitude": 40.164229,
"longitude": 116.294819,
"accuracy": 100
}
wd = webdriver.Chrome(r'C:\666\chromedriver.exe')
wd.execute_cdp_cmd("Page.setGeolocationOverride", params)
wd.implicitly_wait(10)
wd.get('https://app.bupt.edu.cn/ncov/wap/default/index')
studentid = wd.find_element_by_xpath('/html/body/div[1]/div[2]/div[1]/input').send_keys('学号')
password = wd.find_element_by_xpath('/html/body/div[1]/div[2]/div[2]/input').send_keys('密码')
wd.find_element_by_class_name('btn').click()
time.sleep(5)
wd.find_element_by_xpath('/html/body/div[1]/div/div/section/div[4]/ul/li[4]/div/div/div[1]/span[1]/i').click()
wd.find_element_by_xpath('/html/body/div[1]/div/div/section/div[4]/ul/li[8]/div/input').click()
time.sleep(3)
wd.find_element_by_xpath('/html/body/div[1]/div/div/section/div[4]/ul/li[9]/div/div/div[2]/span[1]/i').click()
wd.find_element_by_xpath('/html/body/div[1]/div/div/section/div[5]/div/a').click()
time.sleep(1)
wd.find_element_by_class_name('wapcf-btn.wapcf-btn-ok').click()
mail_host = 'smtp.qq.com'
mail_user = ''
mail_pass = ''
sender = ''
receivers = ['']
message = MIMEText('今日份打卡成功!!!', 'plain', 'utf-8')
message['Subject'] = '自动化打卡成功'
message['From'] = sender
message['To'] = receivers[0]
try:
smtpObj = smtplib.SMTP_SSL(mail_host)
smtpObj.connect(mail_host, 465)
smtpObj.login(mail_user, mail_pass)
smtpObj.sendmail(sender,receivers,message.as_string())
smtpObj.quit()
print('success')
except smtplib.SMTPException as e:
print('error', e)
wd.quit()