- 开头
懒是第一生产力 - -
因为需要输入什么的直接选了 selenium , 我的系统是 macos 所以定时用了 crontab 。 windows 可以把 .py 文件打包之后添加到 windows 的定时任务中, 也挺方便的。
- python代码
from selenium import webdriver
from bs4 import BeautifulSoup as bs
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
id = '***'
name = '***'
card = '***'
browser = webdriver.Chrome()
browser.get('http://xgsys.swjtu.edu.cn/SPCP/Web/UserLogin.aspx') //打开
browser.implicitly_wait(10)
pageSource = browser.page_source
soup = bs(pageSource,'lxml')
codesoup = soup.select('.code-img')
code = codesoup[0].string //提取验证码
browser.find_element_by_id('StudentId').clear()
browser.find_element_by_id('StudentId').send_keys(id