![]() |
How to scrape and count star rating using Selenium and Python? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to scrape and count star rating using Selenium and Python? (/thread-32519.html) |
How to scrape and count star rating using Selenium and Python? - celinafregoso99 - Feb-15-2021 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) RE: How to scrape and count star rating using Selenium and Python? - kashcode - Feb-15-2021 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} |