Here's a much simpler way to do this. You can fancy it up however you like but this is the guts of a really simple and fast way to get the ratings.
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.support.wait import WebDriverWait
driver = webdriver.Chrome()
driver.maximize_window()
wait = WebDriverWait(driver, 10)
titles = ['Toy Story 4', 'How To Train Your Dragon', 'Predator: Badlands', 'Harry Potter And The Goblet Of Fire']Fire', 'The Matrix']
for title in titles:
url = f'https://www.bbfc.co.uk/search?q={title}'
driver.get(url)
ratinga = wait.until(EC.visibility_of_element_located((By.CSS_SELECTORXPATH, "divf"//a[.releases//h2[starts-with(text(), span"'{title} (')]]")))
rating = a.find_element(By.CSS_SELECTOR, "span").get_attribute("aria-label").split("-")[1].upper()
actual_title = wait.until(ECa.visibility_of_element_located(find_element(By.CSS_SELECTOR, "div.releases h2"))"h2").text
print(f"{actual_title}: {rating}")
and it outputs
Toy Story 4 (2019): U
How To Train Your Dragon (2025): PG
Predator: Badlands (2024): 12A
Harry Potter And The Goblet Of Fire (2005): 12
The Matrix (1999): 15