数据采集之selenium模拟登录

使用Cookijar完成模拟登录

本博文爬取实例为内部网站,请sduter使用本人账号替换*********(学号),***(姓名)进行登录

复制代码
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

url = "http://210.44.176.97/datajudge/login.aspx"

driver = webdriver.Edge()

driver.get(url)

username_input = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//input[@id='txtUser']"))
)
password_input = WebDriverWait(driver, 10).until(
    EC.element_to_be_clickable((By.XPATH, "//input[@id='txtPass']"))
)

username_input.send_keys("*********")
password_input.send_keys("***")

login_button = driver.find_element(By.XPATH, "//input[@id='btnLogin']")
login_button.click()

print(driver.page_source)

driver.quit()
相关推荐
FriendshipT23 分钟前
Ultralytics:解读 YOLO26 知识蒸馏
人工智能·pytorch·python·深度学习·yolo
BUG研究员_33 分钟前
工具绑定与调用
python·agent
苏灿烤鱼34 分钟前
AI Agent 深拆 | 图能让 AI 决策可追责吗?Semantica 登顶拆解
python·github·agent
Sirius.z9 小时前
第R6周:LSTM实现糖尿病探索与预测
python
名字还没想好☜9 小时前
Python f-string 进阶:数字格式化、对齐填充、调试 = 号与嵌套表达式
开发语言·数据库·python·字符串格式化·f-string
·薯条大王9 小时前
经济实惠玩云服务器|一台云服务器多人共用,子账号配置教程
java·linux·运维·服务器·汇编·c++·python
Dxy123931021610 小时前
Python 如何使用 MySQL 的事务
python·mysql
今儿敲了吗14 小时前
Python ——第三方包
笔记·python
麒麟水手14 小时前
国产银河麒麟系统开发实录:跑通Streamlit,我踩过的6个坑
python
麒麟水手14 小时前
麒麟系统部署检查清单:上线前30分钟,逐项自查这4类问题
python