数据采集之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()
相关推荐
xiaocainiao8817 分钟前
Python 实战:构建 Git 自动化助手
git·python·自动化
nightunderblackcat21 分钟前
新手向:使用Python将多种图像格式统一转换为JPG
开发语言·python
engchina1 小时前
Python PDF处理库深度对比:PyMuPDF、pypdfium2、pdfplumber、pdfminer的关系与区别
开发语言·python·pdf
Lo-Y-eH1 小时前
Openpyxl:Python操作Excel的利器
python·excel
DAWN_T171 小时前
Transforms
pytorch·python·机器学习·jupyter·pycharm
一百天成为python专家1 小时前
python库之jieba 库
开发语言·人工智能·python·深度学习·机器学习·pycharm·python3.11
27669582922 小时前
tiktok 弹幕 逆向分析
java·python·tiktok·tiktok弹幕·tiktok弹幕逆向分析·a-bogus·x-gnarly
cylat2 小时前
Day59 经典时序预测模型3
人工智能·python·深度学习·神经网络
sunshine__sun2 小时前
web网页用postman调用接口测试(超简单方法)
测试工具·postman