from typing import List
import requests
from bs4 import BeautifulSoup


def getPrefix() -> List[str]:
    """
    Get the most up-to-date course prefix list from http://www.adm.uwaterloo.ca/infocour/CIR/SA/under.html

    Parameters:
        None
    
    Return:
        List[str]
    """
    course_prefix = []

    # Access the course prefix website
    prefix_page = requests.get('http://www.adm.uwaterloo.ca/infocour/CIR/SA/under.html')

    # Parse the accessed website page
    prefix_soup = BeautifulSoup(prefix_page.text, 'html.parser')

    # Since all prefix are under select tag in HTML, scrap the information by the select tag.
    all_select = prefix_soup.find_all('select')
    second_select = all_select[1]
    second_select_all_option = second_select.find_all('option')
    for i in second_select_all_option:
        course_prefix.append(i.get('value'))
    return course_prefix