Python Forum
How to scrape and count star rating using Selenium and Python?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to scrape and count star rating using Selenium and Python?
#1
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)
Reply
#2
Usage of Selenium is mandatory? If not then you can simply send GET request to https://shopee dot sg/api/v2/user/get_rating_summary?userid=275295198 response will be json with all review data.

{"version":"f31cba9e5e278ca6073b9df7cea5f92a","data":{"total_avg_star":4.983607,"buyer_rating_summary":{"rating_star":null,"rating_count":[],"rating_total":0},"seller_rating_summary":{"rating_star":4.983607,"rating_count":[0,0,0,1,62],"rating_total":63}},"error_msg":null,"error":0}
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Turtle Star Fill Color Yellow-White Interchanging Color Effect codelab 9 903 Oct-25-2023, 09:09 AM
Last Post: codelab
  Elo rating smartangel 1 480 Jul-08-2023, 03:43 PM
Last Post: deanhystad
  Row Count and coloumn count Yegor123 4 1,268 Oct-18-2022, 03:52 AM
Last Post: Yegor123
  HELP on Unwanted CSV Export Output | Using Selenium to Scrape soothsayerpg 0 1,242 Jun-13-2021, 12:23 PM
Last Post: soothsayerpg
  fpdf star character issue KatMac 3 2,919 May-01-2021, 06:22 PM
Last Post: KatMac
  Reducing JSON character count in Python for a Twitter Bot johnmitchell85 2 45,920 Apr-28-2021, 06:08 PM
Last Post: johnmitchell85
Photo Creating column in python based on the other colums value count Bartek635 2 2,894 Apr-15-2021, 03:47 PM
Last Post: Bartek635
  How to use the count function from an Excel file using Python? jpy 2 4,370 Dec-21-2020, 12:30 AM
Last Post: jpy
  Why there is a star inside randn? new_to_python 4 2,444 Mar-06-2020, 04:45 AM
Last Post: new_to_python
  Beginner at Python. Trying to count certain integer from random string of code kiaspelleditwrong 3 2,367 Oct-14-2019, 10:40 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020