I'm trying to scrape the number of audience ratings from this page https://www.rottentomatoes.com/m/12_years_a_slave (which is 100,000+) using python selenium. I tried all kinds of selenium locators but every time i get NoSuchElementException: error. Here is my code :
import selenium
from selenium import webdriver
driver = webdriver.Chrome('path.exe')
url = 'https://www.rottentomatoes.com/m/12_years_a_slave'
driver.get(url)
def scrape_dom(element):
shadow_root = driver.execute_script('return
arguments[0].shadowRoot', element)
retuen shadow_root
host = driver.find_element_by_tag_name('score-board')
root_1 = scrape_dom(host)
views = root_1.find_element_by_link_text(
'/m/12_years_a_slave/reviews?type=user&intcmp=rt-' + \
'scorecard_audience-score-reviews')
I also tried xpath , css_selector but always error.may you tell me what's wrong with my code?
A simple CSS selector work here.
I get
100,000+ Ratingsprinted out to my console.