我正在通过 selenium 在https://www.indeed.ae/jobs-in-dubai上抓取工作结果的标题。我认为 .text 不起作用。我正在通过转到主网站的 selenium 运行代码,输入选择性关键字,然后从结果中删除所有标题。但是我收到错误,我该如何解决这个错误
这是我的代码
import time
from selenium import webdriver
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.webdriver.common.keys import Keys
Path = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(Path)
driver.get("https://indeed.ae/")
print(driver.title)
search = driver.find_element_by_name("l")
search.send_keys("Dubai")
search.send_keys(Keys.RETURN)
try:
td = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.ID, "resultsCol"))
)
divs = td.find_elements_by_tag_name("div")
for div in divs:
header = div.find_element_by_class_name("title")
print(header)
finally:
driver.quit()
driver.quit()
我收到以下错误
Job Search | Indeed
Traceback (most recent call last):
File "C:/Users/hp/Desktop/python projects/selenium-pycharm/selenium-bot.py", line 24, in <module>
header = div.find_element_by_class_name("title")
File "C:\Users\hp\Desktop\python projects\selenium-pycharm\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 398, in find_element_by_class_name
return self.find_element(by=By.CLASS_NAME, value=name)
File "C:\Users\hp\Desktop\python projects\selenium-pycharm\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 659, in find_element
{"using": by, "value": value})['value']
File "C:\Users\hp\Desktop\python projects\selenium-pycharm\venv\lib\site-packages\selenium\webdriver\remote\webelement.py", line 633, in _execute
return self._parent.execute(command, params)
Process finished with exit code 1
提前致谢
largeQ
相关分类