I’m extracting the user rewiews from IMbd with selenium, but when I try extracting the rating from each review, I receive this error: selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {“method”:”css selector”,”selector”:”.rating-other-user-rating span”}
The html path of the element is:
<div>
<div class="inline-rating"> <div class="ipl-ratings-bar">
<span class="rating-other-user-rating">
<svg class="ipl-icon ipl-star-icon " xmlns="http://www.w3.org/2000/svg" fill="#000000" height="24" viewBox="0 0 24 24" width="24">
<path d="M0 0h24v24H0z" fill="none"></path>
<path d="M12 17.27L18.18 21l-1.64-7.03L22 9.24l-7.19-.61L12 2 9.19 8.63 2 9.24l5.46 4.73L5.82 21z"></path>
<path d="M0 0h24v24H0z" fill="none"></path>
</svg>
<span>4</span><span class="point-scale">/10</span>
</span>
</div>
</div>
<a href="/review/rw3316476/?ref_=tt_urv" class="title"> The Most Over-Rated Show I Have Ever Seen
</a> </div>
</strike>
The code I tried to use is
service = Service(executable_path="chromedriver.exe")
driver = webdriver.Chrome(service=service)
url = 'https://m.imdb.com/title/tt0903747/reviews?ref_=tt_urv'
driver.get(url)
review_elements = driver.find_elements(By.CLASS_NAME, 'review-container')
#I tried searching the rating (in this case 4) with all the following codes, but I receive the error
rating = review_element.find_element(By.CLASS_NAME, 'inline-rating')
rating = review_element.find_element(By.CLASS_NAME, 'ipl-ratings-bar')
rating = review_element.find_element(By.CSS_SELECTOR, '.rating-other-user-rating span')
rating = review_element.find_element(By.CLASS_NAME,'rating-other-user-rating')
It’s odd beacuase I menaged to pick the title, the text, the date and the user name without problems.
Paula Gryglewska is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.