I'm really new to scrapping data and I am having trouble scrapping multiple pages. I'm trying to get the title of an episode as well as the rating for the episode.
I am only successful in getting the first page scrapped and then it won't work after that.
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
url = 'https://www.imdb.com/title/tt0386676/episodes?season=1'
next_season = "//*[@id='load_next_episodes']"
browser = webdriver.Chrome()
browser.get(url)
for season in range(1,10):
i = 1
episodes = browser.find_elements_by_class_name('info')
for episode in episodes:
title = episode.find_element_by_xpath(f'//*[@id="episodes_content"]/div[2]/div[2]/div[{i}]/div[2]/strong/a').text
rating = episode.find_element_by_class_name('ipl-rating-star__rating').text
print(title, rating)
i += 1
browser.find_element_by_xpath(next_season).click()
browser.close()
My output looks like this:
Pilot 7.4
Diversity Day 8.2
Health Care 7.7
The Alliance 7.9
Basketball 8.3
Hot Girl 7.6
