selenium登录4399

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()
posted @ 2019-08-06 20:46  __风  阅读(429)  评论(0编辑  收藏  举报