欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

selenium登录4399

程序员文章站 2022-03-07 17:13:36
```Python from selenium import webdriver from selenium.webdriver.support.wait import WebDriverWait from selenium.webdriver.common.by import By from se... ......
from selenium import webdriver
from selenium.webdriver.support.wait import webdriverwait
from selenium.webdriver.common.by import by
from selenium.webdriver.support import expected_conditions as ec

username = '' # 输入你的4399账号
password = '' # 输入你的4399密码

driver = webdriver.chrome()
wait = webdriverwait(driver, 10)
driver.get('http://www.4399.com/')
# 找到登录入口,并点击
wait.until(ec.element_to_be_clickable((by.css_selector, '#login_tologin'))).click()
# 切入frame
driver.switch_to.frame('popup_login_frame')
# 找到输入框,输入账号密码
wait.until(ec.presence_of_element_located((by.css_selector, '#username'))).send_keys('username')
wait.until(ec.presence_of_element_located((by.css_selector, '#password'))).send_keys('password')
# 点击登录按钮
wait.until(ec.element_to_be_clickable((by.css_selector, '#login_form > fieldset > div.login_hor.ux_login.clearfix > input'))).click()