The idea is: i wanna collect the name of the flat and its price as a list for every flat on the website. Ive made a simple parser on python, but looks like i cant get any values, since it returns an empty list.
My best guess is: i simply cant find the right class/container that contains this info, thats why it returns as an empty list.
# Importing selenium, CSV, and time
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.ui import WebDriverWait
from bs4 import BeautifulSoup
import csv
import time
from webdriver_manager.chrome import ChromeDriverManager
# Running the browser in the background without GPU and Sandbox
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--no-sandbox')
# Using Service and CDM to specify the driver path
service = Service(ChromeDriverManager().install())
# Initializing the driver
driver = webdriver.Chrome(service=service)
# Opening the developer's URL
print("Opening the page...")
driver.get('https://etalongroup.ru/msk/object/voxhall/')
print("The page is opened.")
# Delay for the page to fully load
time.sleep(30)
# Getting the HTML
page_source = driver.page_source
# Closing the driver
driver.quit()
# Parsing HTML with bs4
soup = BeautifulSoup(page_source, 'html.parser')
# List with apartment data
apartments = []
# Searching for prices in <span> text-scarlet
price_elements = soup.find_all('span', class_='th-h4 text-scarlet')
# Searching for titles in <div> 'aria-label'
title_elements = soup.find_all('div', {'aria-label': True})
# Collecting data
for price_element, title_element in zip(price_elements, title_elements):
price = price_element.text.strip()
title = title_element['aria-label'].strip()
apartments.append({'Title': title, 'Price': price})
print(apartments)
# Script completion message
print("The script has finished executing.")
Im expecting a list or a dictionary in return that will run thru the website and collect the data [n123-30 000 000] etc for every object presented