-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
770 lines (625 loc) · 21.8 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
package main
import (
"encoding/json"
"flag"
"fmt"
"io"
"log"
"net/http"
"net/http/cookiejar"
"os"
"strconv"
"strings"
"sync"
"time"
"github.com/PuerkitoBio/goquery"
"github.com/gtuk/discordwebhook"
"github.com/jmoiron/sqlx"
"github.com/joho/godotenv"
_ "github.com/lib/pq"
)
type termData struct {
Count int `json:"totalCount"`
Courses []course `json:"data"`
}
type course struct {
ID int `json:"id" db:"courseId"`
Ref string `json:"courseReferenceNumber" db:"courseReferenceNumber"`
Number string `json:"courseNumber" db:"courseNumber"`
Subject string `json:"subject" db:"subject"`
Type string `json:"scheduleTypeDescription" db:"scheduleTypeDescription"`
Title string `json:"courseTitle" db:"courseTitle"`
DescriptionUrl string `json:"" db:"descriptionUrl"`
Description string `json:"" db:"description"`
Credits float32 `json:"creditHours" db:"creditHours"`
MaxEnrollment int `json:"maximumEnrollment" db:"maximumEnrollment"`
Enrolled int `json:"enrollment" db:"enrollment"`
Availability int `json:"seatsAvailable" db:"seatsAvailable"`
Faculty []faculty `json:"faculty"`
MeetingsFaculty []meetingsFaculty `json:"meetingsFaculty"`
Attributes []attribute `json:"sectionAttributes"`
Year string `db:"year"`
LinkedSectionUrl string `json:""`
IsSectionLinked bool `json:"isSectionLinked"`
LinkedSections string `db:"linkedSections"`
FacultyID int `db:"facultyId"`
FacultyMeetID int `db:"facultyMeetId"`
}
type faculty struct {
ID string `json:"bannerId" db:"bannerId"`
Ref string `json:"courseReferenceNumber" db:"courseReferenceNumber"`
Name string `json:"displayName" db:"displayName"`
Email string `json:"emailAddress" db:"emailAddress"`
Year string `db:"year"`
Uid string `db:"uid"`
}
type meetingsFaculty struct {
Section string `json:"category" db:"category"`
Ref string `json:"courseReferenceNumber" db:"courseReferenceNumber"`
Year string `db:"year"`
MeetingTimeID int `db:"meetingTimeID"`
MeetingTime meetingTime
}
type meetingTime struct {
Begin string `json:"beginTime" db:"beginTime"`
BEGINTIME time.Time `db:"BEGINTIME"`
ENDTIME time.Time `db:"ENDTIME"`
BuildingShort string `json:"building" db:"building"`
BuildingLong string `json:"buildingDescription" db:"buildingDescription"`
Room string `json:"room" db:"room"`
Section string `json:"category" db:"category"`
Ref string `json:"courseReferenceNumber" db:"courseReferenceNumber"`
EndDate string `json:"endDate" db:"endDate"`
EndTime string `json:"endTime" db:"endTime"`
StartDate string `json:"startDate" db:"startDate"`
Hours float32 `json:"hoursWeek" db:"hoursWeek"`
TypeShort string `json:"meetingType" db:"meetingType"`
TypeLong string `json:"meetingTypeDescription" db:"meetingTypeDescription"`
Monday bool `json:"monday" db:"monday"`
Tuesday bool `json:"tuesday" db:"tuesday"`
Wednesday bool `json:"wednesday" db:"wednesday"`
Thursday bool `json:"thursday" db:"thursday"`
Friday bool `json:"friday" db:"friday"`
Saturday bool `json:"saturday" db:"saturday"`
Sunday bool `json:"sunday" db:"sunday"`
Year string `db:"year"`
}
type linkedSectionsList struct {
LinkedData [][]struct {
CourseReferenceNumber string `json:"courseReferenceNumber"`
} `json:"linkedData"`
}
type attribute struct {
CodeShort string `json:"code" db:"code"`
CodeLong string `json:"description" db:"description"`
Ref string `json:"courseReferenceNumber" db:"courseReferenceNumber"`
Year string `db:"year"`
CourseID int `db:"courseId"`
}
type attribute_list struct {
attributes []attribute
}
var semester, year,env_dir string
var classCount int
func send_to_db(data termData, semester string, year string) {
var MeetingTimeID int
var MeetingsFacultyID int
var facultyID int
var courseID int
var sectionAttributeID int
var yearString string
if strings.ToLower(semester) == "fall" {
yearString = "F" + year
} else {
yearString = "S" + year
}
fmt.Println(yearString)
err := godotenv.Load(env_dir)
if err != nil {
log.Fatalf("Error loading .env file")
}
var host = os.Getenv("HOST")
var port = 5432
var user = os.Getenv("SQL_USER")
var password = os.Getenv("PASS")
var dbname = os.Getenv("DBNAME")
psqlInfo := fmt.Sprintf("host=%s port=%d user=%s "+"password=%s dbname=%s sslmode=disable", host, port, user, password, dbname)
db := sqlx.MustConnect("postgres", psqlInfo)
db.SetMaxOpenConns(80)
defer db.Close()
err = db.Ping()
if err != nil {
panic(err)
}
fmt.Println("Successfully connected to DB!")
for k := range data.Courses {
if len(data.Courses[k].Faculty) > 0 {
query := `INSERT INTO "Faculty"("bannerId",
"uid",
"displayName",
"emailAddress",
"year")
VALUES (:bannerId,
:uid,
:displayName,
:emailAddress,
:year)
ON CONFLICT ("uid")
DO UPDATE SET
"bannerId" = :bannerId, "displayName"= :displayName, "emailAddress"= :emailAddress , "uid" =:uid RETURNING id;`
var data1 faculty = data.Courses[k].Faculty[0]
data1.Ref = yearString + data1.Ref
data1.Year = yearString
data1.Uid = strings.Replace(data1.Name, ", ", "", -1) + data.Courses[k].Subject
rows, err := db.NamedQuery(query, data1)
if err != nil {
log.Fatalln(err)
}
if rows.Next() {
rows.Scan(&facultyID)
}
rows.Close()
}
//Meeting Time
if len(data.Courses[k].MeetingsFaculty) > 0 {
MeetingTimeID = 0
query := `INSERT INTO "MeetingTime" ("beginTime",
"building",
"buildingDescription",
"room",
"category",
"courseReferenceNumber",
"endDate",
"endTime",
"startDate",
"hoursWeek",
"meetingType",
"meetingTypeDescription",
"monday",
"tuesday",
"wednesday",
"thursday",
"friday",
"saturday",
"sunday",
"year")
VALUES (:beginTime,
:building,
:buildingDescription,
:room,
:category,
:courseReferenceNumber,
:endDate,
:endTime,
:startDate,
:hoursWeek,
:meetingType,
:meetingTypeDescription,
:monday,
:tuesday,
:wednesday,
:thursday,
:friday,
:saturday,
:sunday,
:year)
ON CONFLICT ("courseReferenceNumber")
DO UPDATE SET
"beginTime" = :beginTime,
"building" = :building,
"buildingDescription" = :buildingDescription,
"room" = :room,
"category" = :category,
"courseReferenceNumber" = :courseReferenceNumber,
"endDate" = :endDate,
"endTime" = :endTime,
"startDate" = :startDate,
"hoursWeek" = :hoursWeek,
"meetingType" = :meetingType,
"meetingTypeDescription" = :meetingTypeDescription,
"monday" = :monday,
"tuesday" = :tuesday,
"wednesday" = :wednesday,
"thursday" = :thursday,
"friday"= :friday,
"saturday"= :saturday,
"sunday" = :sunday ,
"year"= :year
RETURNING id;`
var data1 meetingTime = data.Courses[k].MeetingsFaculty[0].MeetingTime
if data1.Begin != "" {
var beginTime = data1.Begin
hour, _ := strconv.Atoi(beginTime[0:2])
min, _ := strconv.Atoi(beginTime[2:4])
theTime := time.Date(2005, 05, 15, hour, min, 00, 00, time.UTC)
leTime, _ := time.Parse(time.RFC3339Nano, theTime.Format(time.RFC3339))
data1.BEGINTIME = leTime
}
if data1.EndTime != "" {
var EndTime = data1.EndTime
hour, _ := strconv.Atoi(EndTime[0:2])
min, _ := strconv.Atoi(EndTime[2:4])
theTime := time.Date(2005, 05, 15, hour, min, 00, 00, time.UTC)
leTime, _ := time.Parse(time.RFC3339, theTime.Format(time.RFC3339))
data1.ENDTIME = leTime
}
data1.Ref = yearString + data1.Ref
data1.Year = yearString
rows, err := db.NamedQuery(query, data1)
if err != nil {
log.Fatalln(err)
}
if rows.Next() {
rows.Scan(&MeetingTimeID)
}
rows.Close()
}
//Meeting Faculty
if len(data.Courses[k].MeetingsFaculty) > 0 {
MeetingsFacultyID = 0
query := `INSERT INTO "MeetingsFaculty" ("category",
"courseReferenceNumber",
"meetingTimeID",
"year")
VALUES (:category,
:courseReferenceNumber,
:meetingTimeID,
:year)
ON CONFLICT ("courseReferenceNumber")
DO UPDATE SET
"category" = :category, "meetingTimeID"= :meetingTimeID , "year" = :year RETURNING id;`
var data1 meetingsFaculty = data.Courses[k].MeetingsFaculty[0]
data1.Ref = yearString + data1.Ref
data1.Year = yearString
data1.MeetingTimeID = MeetingTimeID
rows, err := db.NamedQuery(query, data1)
if err != nil {
log.Fatalln(err)
}
if rows.Next() {
rows.Scan(&MeetingsFacultyID)
}
rows.Close()
}
courseID = 0
query := `INSERT INTO "Course"("courseId",
"courseReferenceNumber",
"courseNumber",
"subject",
"scheduleTypeDescription",
"courseTitle",
"descriptionUrl",
"description",
"creditHours",
"maximumEnrollment",
"enrollment",
"seatsAvailable",
"facultyId",
"facultyMeetId",
"year",
"linkedSections"
)
VALUES (:courseId,
:courseReferenceNumber,
:courseNumber,
:subject,
:scheduleTypeDescription,
:courseTitle,
:descriptionUrl,
:description,
:creditHours,
:maximumEnrollment,
:enrollment,
:seatsAvailable,
:facultyId,
:facultyMeetId,
:year,
:linkedSections
)
ON CONFLICT ("courseReferenceNumber")
DO UPDATE SET
"courseId" = :courseId,
"courseNumber" = :courseNumber,
"subject" = :subject,
"scheduleTypeDescription" = :scheduleTypeDescription,
"courseTitle" = :courseTitle,
"descriptionUrl" = :descriptionUrl,
"description" = :description,
"creditHours" = :creditHours,
"maximumEnrollment" = :maximumEnrollment,
"enrollment" = :enrollment,
"seatsAvailable" = :seatsAvailable,
"facultyId" = :facultyId,
"facultyMeetId" = :facultyMeetId,
"linkedSections" = :linkedSections,
"year" = :year RETURNING id;`
var data1 course = data.Courses[k]
data1.Ref = yearString + data1.Ref
data1.FacultyID = facultyID
data1.FacultyMeetID = MeetingsFacultyID
data1.Year = yearString
rows, err := db.NamedQuery(query, data1)
if err != nil {
log.Fatalln(err)
}
if rows.Next() {
rows.Scan(&courseID)
}
rows.Close()
//Attributes
if len(data.Courses[k].Attributes) > 0 {
sectionAttributeID = 0
query := `INSERT INTO "sectionAttribute" ("code",
"description",
"courseReferenceNumber",
"courseId",
"year")
VALUES (:code,
:description,
:courseReferenceNumber,
:courseId ,
:year)
ON CONFLICT ("courseReferenceNumber")
DO UPDATE SET
"code" = :code,
"description" = :description,
"courseId" = :courseId ,
"year" = :year
RETURNING id;`
var data1 = data.Courses[k].Attributes
for z := range data1 {
// perform an operation
data1[z].Ref = yearString + data1[z].Ref + data1[z].CodeShort
data1[z].CourseID = courseID
data1[z].Year = yearString
rows, err = db.NamedQuery(query, data1[z])
if err != nil {
log.Fatalln(err)
}
if rows.Next() {
rows.Scan(§ionAttributeID)
}
rows.Close()
}
}
}
}
func timer(name string) func() {
start := time.Now()
//var username = "Scraper Bot"
var color = "14177041"
var username = "Swat Scraper"
var iconURL = "https://images.sidearmdev.com/convert?url=https%3a%2f%2fdxbhsrqyrr690.cloudfront.net%2fsidearm.nextgen.sites%2fswarthmoreathletics.com%2fimages%2f2021%2f5%2f21%2fsc_logo_g2_rgb.png&type=webp"
var truer = true;
var countTitle = "Course count"
var timeName = "Scrape Time"
return func() {
fmt.Printf("%s took %v\n", name, time.Since(start))
//var content = "Scrape of (" + semester + ", " + year + ") took " + time.Since(start).String()
var countContent = strconv.Itoa(classCount)
var title = semester + ", " + year
var timeContent = time.Since(start).String()
var opMode = "OP Mode"
var opModeContent = os.Getenv("OPMODE")
field := discordwebhook.Field{
Name:&timeName,
Value:&timeContent,
Inline: &truer ,
}
field2 := discordwebhook.Field{
Name:&opMode,
Value:&opModeContent,
Inline: &truer ,
}
field3 := discordwebhook.Field{
Name:&countTitle,
Value:&countContent,
Inline: &truer ,
}
author := discordwebhook.Author{
Name:&username,
IconUrl: &iconURL,
}
embed := discordwebhook.Embed{
Title: &title,
Author: &author,
Color: &color,
Fields: &[]discordwebhook.Field{field2,field3,field},
}
message := discordwebhook.Message{
Username: &username,
Embeds: &[]discordwebhook.Embed{embed},
}
err := discordwebhook.SendMessage(os.Getenv("WEBHOOK"), message)
if err != nil {
log.Fatal(err)
}
}
}
func setTerm(semester string, year string) string {
var term strings.Builder
term.WriteString(year)
if semester == "fall" {
term.WriteString("04")
} else {
term.WriteString("02")
}
return term.String()
}
func requestCourses(term string, offset string, max string, client http.Client) (*termData, error) {
// Note: Endpoint is limited to 500 courses per request, we'll use some sort of pagination
// Will probably not exceed 1000 courses so, for now, 2 requests will be enough
var swarthmoreUrl strings.Builder
swarthmoreUrl.WriteString("https://studentregistration.swarthmore.edu/StudentRegistrationSsb/ssb/searchResults/searchResults?txt_term=")
swarthmoreUrl.WriteString(term)
swarthmoreUrl.WriteString("&startDatepicker=&endDatepicker=&uniqueSessionId=cwtoq1717225731537&pageOffset=")
swarthmoreUrl.WriteString(offset)
swarthmoreUrl.WriteString("&pageMaxSize=")
swarthmoreUrl.WriteString(max)
swarthmoreUrl.WriteString("&sortColumn=subjectDescription&sortDirection=asc")
resp, err := client.Get(swarthmoreUrl.String())
if err != nil {
return nil, fmt.Errorf("failed to fulfill GET request: %w", err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
return nil, fmt.Errorf("failed to read response body: %w", err)
}
data := new(termData)
if err := json.Unmarshal(body, data); err != nil {
return nil, fmt.Errorf("failed to unmarshal JSON: %w", err)
}
return data, nil
}
func getCourseDescriptionUrls(term string, data termData) {
for i := range data.Courses {
var formattedUrl strings.Builder
formattedUrl.WriteString("https://studentregistration.swarthmore.edu/StudentRegistrationSsb/ssb/searchResults/getCourseDescription?term=")
formattedUrl.WriteString(term)
formattedUrl.WriteString("&courseReferenceNumber=")
formattedUrl.WriteString(data.Courses[i].Ref)
url := formattedUrl.String()
data.Courses[i].DescriptionUrl = url
}
}
func getCourseLinkedSectionsUrls(term string, data termData) {
for i := range data.Courses {
var formattedUrl strings.Builder
formattedUrl.WriteString("https://studentregistration.swarthmore.edu/StudentRegistrationSsb/ssb/searchResults/fetchLinkedSections?term=")
formattedUrl.WriteString(term)
formattedUrl.WriteString("&courseReferenceNumber=")
formattedUrl.WriteString(data.Courses[i].Ref)
url := formattedUrl.String()
data.Courses[i].LinkedSectionUrl = url
}
}
func requestCourseLinkedSections(index int, data termData, client http.Client, wg *sync.WaitGroup) {
defer wg.Done()
if data.Courses[index].IsSectionLinked {
resp, err := client.Get(data.Courses[index].LinkedSectionUrl)
if err != nil {
log.Println(err)
}
if err != nil {
fmt.Println("Error fetching linked sections:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
fmt.Println("Error: Received non-200 HTTP status:", resp.StatusCode)
return
}
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
var linkedSections linkedSectionsList
if err := json.Unmarshal(body, &linkedSections); err != nil {
fmt.Printf("Failed to unmarshal JSON: %v\n", err)
return
}
var courseReferenceNumbers []string
for _, elem := range linkedSections.LinkedData {
courseReferenceNumbers = append(courseReferenceNumbers, elem[0].CourseReferenceNumber)
}
data.Courses[index].LinkedSections = strings.Join(courseReferenceNumbers, ",")
}
}
func requestCourseDescription(index int, data termData, client http.Client, wg *sync.WaitGroup) {
defer wg.Done()
resp, err := client.Get(data.Courses[index].DescriptionUrl)
if err != nil {
fmt.Println(err)
}
defer resp.Body.Close()
body, err := io.ReadAll(resp.Body)
if err != nil {
fmt.Println(err)
}
doc, err := goquery.NewDocumentFromReader(strings.NewReader(string(body)))
if err != nil {
fmt.Println(err)
}
section := doc.Find(`section[aria-labelledby="courseDescription"]`)
_, formattedString, ok := strings.Cut(section.Text(), "Section information text:")
if !ok {
data.Courses[index].Description = "No course description provided. Contact Professor."
} else {
data.Courses[index].Description = strings.TrimSpace(formattedString)
}
}
func main() {
var wg sync.WaitGroup
flag.StringVar(&semester, "semester", "fall", "The semster to scrape")
flag.StringVar(&env_dir, "env", ".env", "Where is your env")
flag.StringVar(&year, "year", "2024", "The year to scrape")
flag.Parse()
term := setTerm(semester, year)
defer timer("main")()
jar, _ := cookiejar.New(nil)
client := http.Client{
Jar: jar,
}
var formattedUrl strings.Builder
formattedUrl.WriteString("https://studentregistration.swarthmore.edu/StudentRegistrationSsb/ssb/term/search?mode=search&term=")
formattedUrl.WriteString(term)
formattedUrl.WriteString("&studyPath=&studyPathText=&startDatepicker=&endDatepicker=&uniqueSessionId=l47z91717271338036")
client.Get("https://studentregistration.swarthmore.edu/StudentRegistrationSsb/ssb/registration")
client.Get("https://studentregistration.swarthmore.edu/StudentRegistrationSsb/ssb/term/termSelection?mode=search")
client.Get("https://studentregistration.swarthmore.edu/StudentRegistrationSsb/ssb/classSearch/getTerms?searchTerm=&offset=1&max=10&_=1717271345154")
client.Get(formattedUrl.String())
fmt.Println("Hydrated client")
processedCourses := 0
var data termData
fmt.Println("Requesting courses")
for {
if processedCourses == 0 {
courses, err := requestCourses(term, "0", "500", client)
if err != nil {
fmt.Println(err)
fmt.Println("retrying in 7 seconds")
time.Sleep(7000 * time.Millisecond)
}
data.Courses = append(data.Courses, courses.Courses...)
data.Count = courses.Count
} else {
courses, err := requestCourses(term, strconv.Itoa(processedCourses), "500", client)
if err != nil {
fmt.Println("retrying in 7 seconds")
time.Sleep(7000 * time.Millisecond)
}
data.Courses = append(data.Courses, courses.Courses...)
}
processedCourses += 500
if processedCourses >= data.Count {
classCount = data.Count;
fmt.Println("Finished processing:", data.Count, "courses")
break
}
}
getCourseDescriptionUrls(term, data)
getCourseLinkedSectionsUrls(term, data)
for i := range data.Courses {
wg.Add(2)
go requestCourseDescription(i, data, client, &wg)
go requestCourseLinkedSections(i, data, client, &wg)
}
wg.Wait()
fmt.Println("Reformatting JSON")
courseMap := make(map[int]course)
for k := range data.Courses {
courseMap[data.Courses[k].ID] = data.Courses[k]
}
output, err := json.MarshalIndent(courseMap, "", "\t")
if err != nil {
fmt.Println(err)
}
err = os.WriteFile("courses.json", output, 0644)
fmt.Println("Attempting db connection... ")
send_to_db(data, semester, year)
if err != nil {
fmt.Println(err)
}
}