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.imooc.com/')
# 登录入口
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#js-signin-btn'))).click()
# 输入账号密码
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#signup-form > div:nth-child(1) > input'))).send_keys(USERNAME)
wait.until(EC.presence_of_element_located((By.CSS_SELECTOR, '#signup-form > div:nth-child(2) > input'))).send_keys(PASSWORD)
# 点击登录按钮
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, '#signup-form > div:nth-child(6) > input'))).click()