0

I'm attempting to find all occurrences of a particular class on the webpage https://uk.indeed.com/jobs?q=python&l=York but selenium is just returning an empty list. The eventual aim is to extract the job title names of each position, but i can't seem to retrieve the initial data.

from selenium import webdriver


url = 'https://uk.indeed.com/jobs?q=python&l=York'

driver = webdriver.Firefox()

driver.get(url)


jobs = driver.find_elements_by_class_name("jobsearch-SerpJobCard unifiedRow row result clickcard")

print(jobs)

I have also tried using WebDriverWait but i get no return again, not even an empty list but instead just nothing? Is it maybe something to do with the way i'm using the class name? As when i use the XPATH i can get some data back.

Here is the WebDriverWait code attempt.

from pprint import pprint
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By


url = 'https://uk.indeed.com/jobs?q=python&l=York'

driver = webdriver.Firefox()

driver.get(url)


jobs = WebDriverWait(driver, 10).until(EC.presence_of_all_elements_located((By.CLASS_NAME, 'jobsearch-SerpJobCard unifiedRow row result clickcard')))

1 Answer 1

3

The problem, I think, is that you have spaces in the class name and that doesn't work right. Instead of

jobs = driver.find_elements_by_class_name("jobsearch-SerpJobCard unifiedRow row result clickcard")

I would try

jobs = driver.find_elements_by_css_selector(".jobsearch-SerpJobCard.unifiedRow.row.result.clickcard")
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.