数据采集之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()
相关推荐
电饭叔12 小时前
TypeError:unsupported operand type(s) for -: ‘method‘ and ‘int‘
开发语言·笔记·python
老歌老听老掉牙12 小时前
使用贝叶斯因子量化假设验证所需数据量
python·贝叶斯因子·假设
nix.gnehc12 小时前
poetry 常用命令
python·poetry
中冕—霍格沃兹软件开发测试12 小时前
边界值分析:功能测试中的精度利器
人工智能·功能测试·科技·测试工具·appium·bug
一人の梅雨13 小时前
淘宝商品视频接口深度解析:从视频加密解密到多端视频流重构
java·开发语言·python
杼蛘13 小时前
XXL-Job工具使用操作记录
linux·windows·python·jdk·kettle·xxl-job
qq_2290580113 小时前
运行djando项目 配置启动类 label_studio包含前后端启动方法
python·django
qq_2515335913 小时前
查找 Python 中对象使用的内存量
开发语言·windows·python
yaoxin52112313 小时前
269. Java Stream API - Map-Filter-Reduce算法模型
java·python·算法
梨落秋霜13 小时前
Python入门篇【函数】
开发语言·python