<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># CIS 1100 Code from Scraping Lecture II
# Author: The students of CIS1100

from bs4 import BeautifulSoup
import pandas as pd

file = open("rotten_table.html")
soup = BeautifulSoup(file, "html.parser")

rows = soup.find_all("tr")

movies = []

for elem in rows:
    movie = dict()
    movie["title"] = elem.a.string
    movie["year"] = elem.find("span", class_ = "year").string.strip()[1:5]
    movie["score"] = elem.strong.string
    movie["link"] = elem.a["href"]
    movies.append(movie)

df = pd.DataFrame(movies)
df.to_csv("movies.csv", index = False)




</pre></body></html>