我要废弃glassdoor审查的公司名单。要做到这一点,我需要首先登录,以获得访问所有审查。然后,我的方法是输入名称的第一家公司,然后scarp其审查......做同样的所有公司在名单中....要做到这一点,当我去这个网址"www.example.com",https://www.glassdoor.co.in/member/home/index.htm最后一行代码,我将把光标放在"搜索按钮"上。我有这个错误**"AttributeError:"NoneType"对象没有属性"send_keys""the last line of code where I going to send cursor on "search button" . I have this error"AttributeError: 'NoneType' object has no attribute 'send_keys'"**
如果你能帮助我,我将不胜感激!
我使用了以下代码:
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
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.common.exceptions import TimeoutException, WebDriverException
from selenium.webdriver.chrome.options import Options
import time
import pandas as pd
driver_path= r"C:\Users\TMaghsoudi\Desktop\chromedriver_win32.exe"
# chrome options
options = webdriver.ChromeOptions()
# options.add_argument("--start-maximized")
options.add_argument('--ignore-certificate-errors')
options.add_argument('--ignore-ssl-errors')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(driver_path, chrome_options=options)
# set driver
driver = webdriver.Chrome(driver_path, chrome_options=options)
# get url
url = "https://www.glassdoor.co.in/Job/index.htm"
driver.get(url)
time.sleep(3)
driver.find_element(By.CLASS_NAME, "HeaderStyles__signInButton").click()
# singin = WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.ID, "SignInButton")))
# singin.click()
time.sleep(5)
Enter_email= driver.find_element(By.ID, "modalUserEmail")
Enter_email.send_keys("XXXXXX")
Enter_email.send_keys(Keys.ENTER)
Enter_pass= driver.find_element(By.ID,"modalUserPassword")
Enter_pass.send_keys("XXXXX")
SingIn= WebDriverWait(driver, 10).until(EC.presence_of_element_located((By.XPATH, "//div[@class='d-flex align-items-center flex-column']/button[@class='gd-ui-button mt-std minWidthBtn css-1dqhu4c evpplnh0']")))
SingIn.click()
time.sleep(5)
driver.set_window_size(1120, 1000)
driver.find_element(By.CLASS_NAME,"siteHeader__HeaderStyles__navigationItem:nth-child(2)").click()
Company=driver.find_element(By.ID,"sc\.keyword").send_keys("Amazon")
Company.send_keys(Keys.ENTER) **#the error is here!!!!!!**
2条答案
按热度按时间ttisahbt1#
通过运行
您正在将值
None
赋给Company
,这是因为如果.send_keys()
执行无误,它将返回值None
。所以你得跑
您还可以在一行中运行最后两个命令
xzv2uavs2#
若要首先在搜索框中写入,然后不选择列表视图中的第一个索引,可以使用以下locator strategies命令背靠背发送ENTER: