created reusable text component, and setup typing for it automatically. also fixed bugs with autoload and scraper so that it would handle appending course name headers

This commit is contained in:
Sriram Hariharan
2023-03-05 17:34:56 -06:00
parent 0956525e94
commit 6147289b40
14 changed files with 161 additions and 48 deletions

View File

@@ -39,9 +39,10 @@ export class CourseCatalogScraper {
/**
* Pass in a list of HTMLtable rows and scrape every course from them
* @param rows the rows of the course catalog table
* @param keepHeaders whether to keep the header rows (which contain the course name) in the output
* @returns an array of course row objects (which contain courses corresponding to the htmltable row)
*/
public scrape(rows: NodeListOf<HTMLTableRowElement> | HTMLTableRowElement[]): ScrapedRow[] {
public scrape(rows: NodeListOf<HTMLTableRowElement> | HTMLTableRowElement[], keepHeaders = false): ScrapedRow[] {
const courses: ScrapedRow[] = [];
let fullName = this.getFullName();
@@ -49,6 +50,12 @@ export class CourseCatalogScraper {
rows.forEach(row => {
if (this.isHeaderRow(row)) {
fullName = this.getFullName(row);
if (keepHeaders) {
courses.push({
element: row,
course: null,
});
}
return;
}
// we are now ready to build the course object