数据采集之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()
相关推荐
名字还没想好☜8 小时前
Python 字符编码实战:encode/decode、UnicodeDecodeError 与 open 的 encoding 坑
开发语言·后端·python·编程语言
带多刺的玫瑰8 小时前
Leecode#29刷题之两数相除
java·python·算法
smj2302_796826528 小时前
解决leetcode第4017题数组中的峰值II
python·算法·leetcode
卷无止境8 小时前
AI Agent编程中,重构节奏与安全检查的门道
后端·python
慧都小妮子8 小时前
用 Python 批量把 PDF 参考文献排成 MLA 格式:Spire.Doc for Python 实战
python·pdf·c#·spire.doc·mla格式·参考文献排版·pdf批量处理
卷无止境8 小时前
AI编程时代,代码复杂性正在悄悄失控
后端·python
开源量化GO9 小时前
看到“2026年 Python 与 API”时,用示例和拆解看清关系
人工智能·python
高洁019 小时前
大模型是怎么“学会“的:预训练、微调、对齐三段论
python·深度学习·transformer·知识图谱·tornado
529宝宝起名网9 小时前
用 Python 开发名字五行八字匹配工具:从八字排盘到喜用神起名的全流程实现
python
Luminbox紫创测控9 小时前
一文读懂:准直太阳模拟器如何检测汽车AR-HUD阳光倒灌
测试工具·汽车·ar·安全性测试·太阳光模拟器·测试标准·阳光倒灌