14. Course Data Web Scraper (Points: 10)

Create a web scraper that extracts course data from the Carleton Central schedule page. The scraper should retrieve details such as course codes, titles, and available sections for a given term.

If you’re not sure where to get started, here is some starter code:

import axios from 'axios';
import * as cheerio from 'cheerio';  // Use this syntax for compatibility

const scrapeData = async () => {
  const { data } = await axios.get('https://central.carleton.ca/prod/bwysched.p_select_term?wsea_code=EXT');
  console.log(data);  // Logs raw HTML content
  
  const $ = cheerio.load(data);  // Initialize Cheerio with loaded HTML
  console.log($('title').text());  // Example: Print the <title> content
};

scrapeData();

To run this code, you’ll have to npm i axios and npm i cheerio.

Acceptance Criteria:

  1. The web scraper successfully extracts course data, including course codes, titles, and sections.
  2. The scraper is able to parse data from at least one term and one program from the provided website.
  3. The scraped data is outputted in a structured format, such as JSON or CSV.