首页 > 解决方案 > How to scrape star ratings using Selenium or Beautifulsoup in Python?

问题描述

I am trying to scrape the ratings based on stars. The stars are in different colors and can be distinguished in Chrome. However, the stars are all the same in the tags. Is there a way to scrape the rating for each sub-category based on the color of the stars, e.g., Work/Life Balance should have a rating of 3.

The webpage can be found here: https://www.glassdoor.ca/Reviews/Employee-Review-AAR-RVW40036525.htm

enter image description here
enter image description here

标签: pythonseleniumbeautifulsoup

解决方案


为了区分评级,每个评级类别的类名称都不同。这是一个基于等级的所有类名的示例,值是类名。这可以让你从你需要的东西开始

{
"one_star" : "css-152xdkl",
"two_star" : "css-19o85uz",
"three_star" : "css-1ihykkv",
"four_star" : "css-1c07csa",
"five_star" : "css-1dc0bv4",
}

推荐阅读