from selenium import webdriver
import time
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
driver = webdriver.Chrome()
option = webdriver.ChromeOptions()
option.add_experimental_option("detach", True)
option.add_argument('--ignore-certificate-errors')
option.add_experimental_option('excludeSwitches', ['enable-automation'])
option.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(options=option)
driver.get("https://www.zhaopin.com/")
time.sleep(2)
driver.find_element(By.XPATH,"/html/body/div[1]/main/div[1]/div[2]/div/div/div/div/div/div/div/div/div[1]/div").click()
time.sleep(10)
station = input("请输入你要搜索的岗位")
while True:
mask_element = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH, "/html/body/div[2]"))
)
if mask_element:
print(mask_element.text)
driver.quit()
else:
driver.get("https://sou.zhaopin.com/?jl=765&kw="+station)
driver.find_element(By.XPATH,"/html/body/div/div[4]/div[2]/div[2]/div/div[31]/div[1]/div/div[1]/i").click()
driver.find_element(By.XPATH,"/html/body/div/div[4]/div[2]/div[2]/div/div[31]/div[1]/div/div[2]/div[2]/button").click()