title: How to scrape and count star rating using Selenium and Python?
body: <p>I am currently trying to scrape the reviews on this particular website: <a href="https://shopee.sg/buyer/275295198/rating" rel="nofollow noreferrer">https://shopee.sg/buyer/275295198/rating</a> 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:</p>
  <p>This is the current code i have for counting and summing the filled stars, but seem to only return 1:</p>
  <pre><code>    # Star rating
        star_ratings = product.find_elements_by_css_selector(&quot;[class='shopee-product-rating__rating']&quot;)
        stars = product.find_elements_by_css_selector(&quot;[class='shopee-svg-icon icon-rating-solid--active icon-rating-solid']&quot;)
  
        star_rate = 0
        for rating in star_ratings:
            #print(rating.get_attribute('svg'))
            if (product.find_elements_by_css_selector(&quot;[class='shopee-svg-icon icon-rating-solid--active icon-rating-solid']&quot;)) == stars:
                star_rates = star_rate + 1
                continue
        rating_csv.append(star_rates)
        print(star_rates)
  </code></pre>