cmd 安装
pip install selenium
webdriver 下载 选择"x64"
!!!driver 是会更新的py启动不了就说明driver 跟新了要重下!!!
Microsoft Edge WebDriver - Microsoft Edge Developer
"msedgedriver.exe"改名为“MicrosoftWebDriver.exe”
代码
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
import time
def Zhao():
username = "学号"
password = "密码"
browser = webdriver.Edge('webdriver的位置')
browser.get('https://ehall.szpt.edu.cn/publicappinternet/sys/szptpubxsjkxxbs/index.do?t_s=1648449299574#/mrxxbs')
user = browser.find_element_by_id("username")
user.send_keys(username)
browser.find_element_by_id("password").send_keys(password)
browser.find_element_by_xpath("//button").click()
time.sleep(4)
browser.find_element_by_css_selector('body > main > article > section > div.bh-btn-grouped.bh-mb-16 > div.bh-pull-left > button').click()
time.sleep(6)
browser.execute_script('window.scrollBy(0,10000)')
browser.find_element_by_xpath('//*[@id="promise"]/label/input').click()
time.sleep(2)
browser.find_element_by_xpath('//*[@id="submit"]').click()
browser.find_element_by_link_text("确认").click()
time.sleep(3)
browser.get('https://ehall.szpt.edu.cn/publicappinternet/sys/szptpubhsjcqd/*default/index.do?nodeId=0&taskId=0&processInstanceId=0&instId=0&defId=0&defKey=0#/')
time.sleep(1)
try:
browser.find_element_by_xpath("//*[@id='app']/div/div/div/button").click()
time.sleep(1)
browser.find_element_by_xpath("/html/body/div[3]/div/div[3]/button[2]").click()
time.sleep(5)
except:
pass
if __name__ == '__main__':
Zhao()
a = time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time()))
b = "健康填报已完成,每日核算已完成\n"
c = a + b
with open("健康.txt","w") as f:
f.write(c) # 自带文件关闭功能,不需要再写f.close()
写一个bat 和py都放在桌面
D:
cd D:\Destdrop
start python jian.py
加入电脑任务计划即可