Beginner webscraper using selenium. I’m having trouble navigating to the next page and collecting data. I have only been able to do it on the first page.
I tried pagination by clicking the “Next” button to navigate through additional pages, but I was having a hard time.
from selenium import webdriver
from selenium.webdriver.common.by import By
import csv
driver = webdriver.Chrome()
driver.get("https://www.indeed.com/jobs?q=RN&l=Boston%2C+MA&from=searchOnHP&vjk=a3f093c9230b8574")
e_items = driver.find_elements(By.CLASS_NAME, 'jobTitle')
with open('job_titles.csv', 'w', newline='', encoding='utf-8') as file:
writer = csv.writer(file)
writer.writerow(['Job Title'])
for e_item in e_items:
writer.writerow([e_item.text])
#psuedocode: click on next page pagination-page-{} insert number and += 1 to keep going, and collect data on each page
driver.quit()
New contributor
bozoka96 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.