Skip to content
CFBD
  • AI Chat
  • Code
  • Report
  • import requests
    from bs4 import BeautifulSoup
    
    # Define the URL to scrape
    url = "https://collegefootballdata.com/"
    
    # Send a GET request to the URL
    response = requests.get(url)
    
    # Create a BeautifulSoup object from the HTML content of the response
    soup = BeautifulSoup(response.content, "html.parser")
    
    # Find the table containing the college football data
    table = soup.find("table")
    
    # Extract the rows from the table
    rows = table.find_all("tr")
    
    # Extract the headers from the first row
    headers = [header.text.strip() for header in rows[0].find_all("th")]
    
    # Create an empty list to store the data
    data = []
    
    # Extract the data from the remaining rows
    for row in rows[1:]:
        values = [value.text.strip() for value in row.find_all("td")]
        data.append(dict(zip(headers, values)))
    
    # Print the data
    print(data)