import requests import csv from bs4 import BeautifulSoup import matplotlib.pyplot as plt # Target URL url = "https://cspages.ucalgary.ca/~tam/2025/217F/examples/libraries/simple_table.html" # Fetch the page response = requests.get(url) soup = BeautifulSoup(response.content, "html.parser") # Find the first table table = soup.find("table") # Extract data into a 2D list table_data = [] for row in table.find_all("tr"): row_data = [] for cell in row.find_all(["th", "td"]): row_data.append(cell.text.strip()) if row_data: # skip empty rows table_data.append(row_data) # Print the 2D list for row in table_data: print(row)