老师您好, 我登录拉钩网的时候,登录按钮Click无法点击,手动点击登录也不行!代码如下
来源:7-5 网页302之后的模拟登录和cookie传递(网站需要登录时学习本视频教程)
荼灬
2021-05-21
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)
写回答
1回答
-
import undetected_chromedriver.v2 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)拷贝这个代码运行试试
022021-05-25
相似问题