Feb-15-2021, 11:16 AM
I am currently trying to scrape the reviews on this particular website: https://protigwelders.com but am unable to figure out a way using selenium to scrape star ratings since each star is an svg on its own. Realized that there's a pattern between filled stars and unfilled stars:
This is the current code i have for counting and summing the filled stars, but seem to only return 1:
# Star rating
star_ratings = product.find_elements_by_css_selector("[class='shopee-product-rating__rating']")
stars = product.find_elements_by_css_selector("[class='shopee-svg-icon icon-rating-solid--active icon-rating-solid']")
star_rate = 0
for rating in star_ratings:
#print(rating.get_attribute('svg'))
if (product.find_elements_by_css_selector("[class='shopee-svg-icon icon-rating-solid--active icon-rating-solid']")) == stars:
star_rates = star_rate + 1
continue
rating_csv.append(star_rates)
print(star_rates)
This is the current code i have for counting and summing the filled stars, but seem to only return 1:
# Star rating
star_ratings = product.find_elements_by_css_selector("[class='shopee-product-rating__rating']")
stars = product.find_elements_by_css_selector("[class='shopee-svg-icon icon-rating-solid--active icon-rating-solid']")
star_rate = 0
for rating in star_ratings:
#print(rating.get_attribute('svg'))
if (product.find_elements_by_css_selector("[class='shopee-svg-icon icon-rating-solid--active icon-rating-solid']")) == stars:
star_rates = star_rate + 1
continue
rating_csv.append(star_rates)
print(star_rates)