How to scrape multiple pages with selenuim I am trying to scrape multiple pages but They show me error Is there any method share with me I am trying to scrape multiple pages by clicking on button these is page link https://www.ifep.ro/justice/lawyers/lawyerspanel.aspx
import time
from selenium import webdriver
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from webdriver_manager.chrome import ChromeDriverManager
options = webdriver.ChromeOptions()
# options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("--disable-gpu")
options.add_argument("--window-size=1920x1080")
options.add_argument("--disable-extensions")
chrome_driver = webdriver.Chrome(
service=Service(ChromeDriverManager().install()),
options=options
)
productlink=[]
def supplyvan_scraper():
with chrome_driver as driver:
driver.implicitly_wait(15)
URL = 'https://www.ifep.ro/justice/lawyers/lawyerspanel.aspx'
driver.get(URL)
time.sleep(3)
links = driver.find_elements_by_xpath("//div[@class='list-group']//a")
for link in links:
link_href = link.get_attribute("href")
if link_href.startswith("https://www.ifep.ro/"):
productlink.append(link_href)
for k in range(1,5):
for product in productlink:
driver.get(product)
time.sleep(2)
title = driver.find_element(By.CSS_SELECTOR, '#HeadingContent_lblTitle').text
d1 = driver.find_element_by_xpath("//div[@class='col-md-10']//p[1]").text
d1 = d1.strip()
d2 = driver.find_element_by_xpath("//div[@class='col-md-10']//p[2]").text
d2 = d2.strip()
d3 =driver.find_element_by_xpath(
"//div[@class='col-md-10']//p[3]//span").text
d3 = d3.strip()
d4 = driver.find_element_by_xpath("//div[@class='col-md-10']//p[4]").text
d4 = d4.strip()
WebDriverWait(driver, 10).until( EC.visibility_of_element_located((By.ID, f"MainContent_PagerTop_NavToPage{k}")) ).click()
print(title,d1,d2,d3,d4)
# driver.back()
time.sleep(2)
driver.quit()
supplyvan_scraper()