【问题标题】:Use python script to Easy Apply on linkedin using selenium使用 python 脚本使用 selenium 在linkedin上轻松应用
【发布时间】:2022-08-22 05:26:25
【问题描述】:

我试图让脚本运行一个循环,在该循环中单击列表中的每个作业,但不断出错。作为参考,我正在尝试关注THIS 教程

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import time

username_input = \"email@gmail.com\"
password_imput = \"password\"

driver = webdriver.Chrome(\"C:/Users/JUAN/Documents/chromedriver/chromedriver.exe\")
driver.get(\"https://www.linkedin.com/jobs/search/?f_AL=true&geoId=100446943&keywords=data%20analyst&location=Argentina\")

sign_in_button = driver.find_element(\"link text\",\"Sign in\")
sign_in_button.click()

email_field = driver.find_element(\"id\", \"username\")
email_field.send_keys(username_input)

password_field = driver.find_element(\"id\",\"password\")
password_field.send_keys(password_imput)
password_field.send_keys(Keys.ENTER)
time.sleep(3)
all_listings = driver.find_element(\"css selector\",\"job-card-container--clickable\")

for listing in all_listings:
    print(\"called\")
    listing.click()
    time.sleep(2)

收到此错误:

selenium.common.exceptions.NoSuchElementException:消息:没有这样的元素:无法找到元素:{\“方法\”:\“css选择器\”,\“选择器\”:\“job-card-container--clickable\ "} (会话信息:chrome=103.0.5060.114)

    标签: python selenium-webdriver css-selectors linkedin


    【解决方案1】:

    尝试替换:

    all_listings = driver.find_element("css selector","job-card-container--clickable")
    

    和:

    from selenium.webdriver.common.by import By
    xpath = "//*[contains(@class,'job-card-container--clickable')]"
    all_listings = driver.find_element(by=By.XPATH, value=xpath)
    

    【讨论】:

    • 试过这个也不管用,谢谢你的回复
    【解决方案2】:
      all_listings = driver.find_element("css selector","job-card-container--clickable")
    

    因为我使用的是find_element 而不是find_elements(复数形式),所以它不可迭代,因为它只包含一个

    all_listings = driver.find_elements("css selector",".job-card-container--clickable")
    

    解决它

    【讨论】:

      【解决方案3】:

      当我尝试

      all_listings = driver.find_elements(By.CLASS_NAME,'job-card-container--clickable')
      

      它没有给我完整的链接列表。似乎它也给了我随机列表。

      【讨论】:

        猜你喜欢
        • 2019-02-06
        • 2012-01-30
        • 1970-01-01
        • 2011-04-10
        • 2016-03-05
        • 1970-01-01
        • 1970-01-01
        • 2021-12-19
        • 1970-01-01
        相关资源
        最近更新 更多