#!/usr/bin/python import glob import os from bs4 import BeautifulSoup import re basepath = "/Volumes/Untitled2/archive-dgst101-net/" folders = glob.glob(basepath + "p/*") name_map = { 'f18' : "Fall 2018", 's19' : "Spring 2019", 'su19' : "Summer 2019", 'dgst395' : "DGST 395: Applied Digital Studies", 'dgst301A' : "DGST 301A: Creative Coding", 'dgst101' : "DGST 101: Introduction to Digital Studies" } structure = {} for folder in folders: index = folder + "/index.html" if (os.path.isfile(index)): #print("Found " + index) with open(index, "r") as f: soup = BeautifulSoup(f, 'html.parser') title = soup.h1.text.strip() #what = soup. fields = soup.find_all('td') student_name = fields[0].text.strip() student_name = re.sub(r"\(\d{4}\)","",student_name,re.IGNORECASE) semester = str(folder.split("-")[-1]) course = str(folder.split("-")[-2]) if (semester not in structure): structure[semester] = {} if (course not in structure[semester]): structure[semester][course] = [] structure[semester][course].append("
") for semester,courses in structure.items(): print("