0.个人操作记录:【自动登录传智播客】
Ⅰ下载最新版本Chrome浏览器:(稳定版——版本 101.0.4951.54(正式版本) (64 位))![](https://img-blog.csdnimg.cn/fdb00bd27ce24f95a2701c4bd826159a.png)
Ⅱ下载并配置相近版本的chromedriver.exe:
CNPM Binaries Mirror :https://registry.npmmirror.com/binary.html?path=chromedriver/
Ⅲ将下载好的安装包解压,并将解压的文件放到Chrome浏览器的文件夹中(右键->打开文件所在位置)![](https://img-blog.csdnimg.cn/5d31c1ea159f43b6b806f843c2db4a03.png)
Ⅳ配置环境变量(如图:笔误:①右键->属性)
ⅤPython代码: 密码、账号请自行修改,否则在弹出页面中无法自动登录。
from selenium import webdriver
import time
driver=webdriver.Chrome(executable_path='C:\Program Files\Google\Chrome\Application\chromedriver.exe')
driver.get('http://stu.ityxb.com/')
driver.find_element_by_xpath('//span[@class="login-btn primary-linear"]').click()
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div/div/div[1]/div[1]').click()
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div/div[2]/div/div[1]/div[2]/div[1]/form/div[1]/span/div/input').send_keys('your username')
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div/div[2]/div/div[1]/div[2]/div[1]/form/div[2]/span/div/input').send_keys('your password')
driver.find_element_by_xpath('/html/body/div[1]/div[2]/div/div/div[2]/div/div[1]/div[2]/div[1]/form/div[3]/button').click()
time.sleep(5)
driver.quit()
&:selenium和webdriver以及代码说明 👆 如上。
效果: