So basically I am trying to work on webscraping. I need to scrap the work life balance rating from indeed website. But the challenge that I am facing is that I do not know how to extract the text from the aria-label, so I can get the output 4.0 out of 5 stars.
<div role="img" aria-label="4.0 out of 5 stars."><div class="css-eub7j6 eu4oa1w0"><div data-testid="filledStar" style="width:42.68px" class="css-i84nrz eu4oa1w0"></div></div></div>
You need to identify the element and use the get attribute aria-label
to get the value.
If you are using python. code will be
print(diver.find_element(By.XPATH, "//div[@role='img']").get_attribute("aria-label"))
Update:
print(diver.find_element(By.XPATH, "//div[@role='img' and @aria-label]").get_attribute("aria-label"))
Or
print(diver.find_element(By.XPATH, "//div[@role='img' and @aria-label][.//div[@data-testid='filledStar']]").get_attribute("aria-label"))