Я использую ссылку https://www.influenster.com/reviews/lor ... -126-fl-oz. Подскажите, пожалуйста, как мне получить звезды, поскольку нет метки арии или числового значения, которое можно было бы очистить.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.chrome.service import Service as ChromeService
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
import configparser
from datetime import datetime
parser = configparser.RawConfigParser()
parser.read('config.ini')
url= parser['PROPERTIES']['URL']
END_DATE = datetime.strptime(parser['DATE']['END'], '%Y-%m-%d')
START_DATE=datetime.strptime(parser['DATE']['START'],'%Y-%m-%d')
# Setting up driver options
options = webdriver.ChromeOptions()
# Setting up Path to chromedriver executable file
CHROMEDRIVER_PATH =r'C:\Users\HP\Desktop\INTERNSHIP\influenster\chromedriver.exe'
# Adding options
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option("useAutomationExtension", False)
# Setting up chrome service
service = ChromeService(executable_path=CHROMEDRIVER_PATH)
# Establishing Chrom web driver using set services and options
driver = webdriver.Chrome(service=service, options=options)
wait = WebDriverWait(driver, 20)
driver.get(url)
# The 2 lines below is what I actually added here + necessary imports
# and `wait` object initialization
wait.until(EC.element_to_be_clickable((By.CSS_SELECTOR, "button#onetrust-accept-btn-handler"))).click()
reviews = wait.until(EC.visibility_of_all_elements_located((By.CSS_SELECTOR, ".conversations-left .item")))
count=0
item_list = []
for review in reviews:
item={
#stars
'username': review.find_element_by_xpath(".//a[contains(@class,'name')]").text,
'userurl':review.find_element_by_xpath(".//a[contains(@class,'name')]").get_attribute("href"),
'title': 'NA',
# 'review_text':review.find_element_by_xpath(".//div[contains(@class,'review-text')]").text,
# 'permalink': 'NA',
# 'date':curr_date,
# 'subproduct name': 'NA',
# 'subproduct link': 'NA',
}
item_list.append(item)
print(item_list)
Подробнее здесь: https://stackoverflow.com/questions/737 ... scrape-the