请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

老师您好, 我登录拉钩网的时候,登录按钮Click无法点击,手动点击登录也不行!代码如下

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)

拷贝这个代码运行试试

0 回复 有任何疑惑可以回复我~
  • 提问者 荼灬 #1
    非常感谢!但是我后面发现根本原因是设置了options=chrome_options,只要把这个参数取消掉就可以运行。目前不知道为什么。
    回复 有任何疑惑可以回复我~ 2021-05-25 09:43:54
  • bobby 回复 提问者 荼灬 #2
    好的,这也是一个很重要的发现,你可以再进一步确定一下是chrome_options中哪个参数引起的就可以猜测到拉勾网是如何排查的
    回复 有任何疑惑可以回复我~ 2021-05-25 10:10:30
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号