WEBDRIVER 即时输入
from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.support.wait import WebDriverWait import time #启动谷歌浏览器 driver=webdriver.Chrome() driver.implicitly_wait(10) # 隐式等待 driver.get(url='https://www.liepin.com/zhaopin/?init=1') try: element = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="header-quick-menu-login"]'))) finally: element = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="header-quick-menu-login"]'))) element.click() time.sleep(5) try: element1 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[4]/div/div[2]/div/div[2]/div/div/div[1]/div/div/div[1]/div[2]/div/div[3]/div/label/span[1]/input'))) finally: element1 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[4]/div/div[2]/div/div[2]/div/div/div[1]/div/div/div[1]/div[2]/div/div[3]/div/label/span[1]/input'))) element1.click() try: element2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[4]/div/div[2]/div/div[2]/div/div/div[1]/div/div/div[1]/div[2]/div/div[4]/span'))) finally: element2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[4]/div/div[2]/div/div[2]/div/div/div[1]/div/div/div[1]/div[2]/div/div[4]/span'))) element2.click() try: element2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="login"]'))) finally: element2 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="login"]'))) element2.send_keys("13336989816") try: element3 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="pwd"]'))) finally: element3 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '//*[@id="pwd"]'))) element3.send_keys("133369869816") try: element4 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[4]/div/div[2]/div/div[2]/div/div/div[1]/div/div/div[1]/div[2]/div/div[2]/div[2]/form/button'))) finally: element4 = WebDriverWait(driver, 30).until(EC.presence_of_element_located((By.XPATH, '/html/body/div[4]/div/div[2]/div/div[2]/div/div/div[1]/div/div/div[1]/div[2]/div/div[2]/div[2]/form/button'))) element4.click()