import undetected_chromedriver as uc
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time
user = "*******"
password = "*********"
url = "https://passport.lagou.com/login/login.html"
uc.TARGET_VERSION = 90
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = uc.Chrome(options=chrome_options)
driver.get(url)
# 输入账号
driver.find_element_by_xpath("//form[@class='active']/div[1]//input[@class='input input_white HtoC_JS']").send_keys(Keys.CONTROL+"a")
driver.find_element_by_xpath("//form[@class='active']/div[1]//input[@class='input input_white HtoC_JS']").send_keys(user)
# 输入密码
driver.find_element_by_xpath("//form[@class='active']/div[2]//input[@class='input input_white HtoC_JS']").send_keys(Keys.CONTROL+"a")
driver.find_element_by_xpath("//form[@class='active']/div[2]//input[@class='input input_white HtoC_JS']").send_keys(password)
# 点击登录按钮
driver.find_element_by_xpath("//div[@class='input_item btn_group clearfix sense_login_password']/input").click()
time.sleep(30)
带你彻底掌握Scrapy,用Django+Elasticsearch搭建搜索引擎
了解课程