from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
USERNAME = '' # 输入账号
PASSWORD = '' # 输入密码
driver = webdriver.Chrome()
driver.maximize_window()
wait = WebDriverWait(driver, 10)
driver.get('https://www.shiyanlou.com')
# 登录入口
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#__layout > div > div.body > div.home > div > div.container > div.row > div > div.home-header > div > div > li.nav-item.base-nav-item.sign-in-btn > a'))).click()
# 输入账号密码
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#__BVID__364'))).send_keys(USERNAME)
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#__BVID__365'))).send_keys(PASSWORD)
# 勾选自动登录
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#sign-modal___BV_modal_body_ > div:nth-child(3) > form > div.remember > div > label'))).click()
# 点击登录按钮
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#sign-modal___BV_modal_body_ > div:nth-child(3) > form > button'))).click()