summaryrefslogtreecommitdiff
path: root/aplus.go
diff options
context:
space:
mode:
authorJuan Roig <jaroig@outlook.com>2023-11-14 22:42:25 -0500
committerJuan Roig <jaroig@outlook.com>2023-11-14 22:42:25 -0500
commite28dc923074ff7445d23cb97a04233f6192a69be (patch)
tree39a3076839b9d79e4e8dbce40280e8943abf11cc /aplus.go
parent329f8dfe029025d591cf3e111dc842a7f4c2a43f (diff)
Add flags, update README
Diffstat (limited to 'aplus.go')
-rw-r--r--aplus.go11
1 files changed, 3 insertions, 8 deletions
diff --git a/aplus.go b/aplus.go
index b9e6a13..a8d4daf 100644
--- a/aplus.go
+++ b/aplus.go
@@ -12,6 +12,9 @@ import (
12 12
13func submit_code(course_code int, attendance_code string) { 13func submit_code(course_code int, attendance_code string) {
14 cur_body := launch_aplus(course_code) 14 cur_body := launch_aplus(course_code)
15
16 fmt.Printf("%s", cur_body)
17
15 current_url := fmt.Sprintf("%s/student/", base_aplus_link) 18 current_url := fmt.Sprintf("%s/student/", base_aplus_link)
16 // the links to submit the code for a class is under the dayPanel div 19 // the links to submit the code for a class is under the dayPanel div
17 daypanel_start := strings.Index(cur_body, "<div class=\"dayPanel\"") 20 daypanel_start := strings.Index(cur_body, "<div class=\"dayPanel\"")
@@ -37,21 +40,13 @@ func submit_code(course_code int, attendance_code string) {
37 resp, _ := client.Get(link_url) 40 resp, _ := client.Get(link_url)
38 body, _ := io.ReadAll(resp.Body) 41 body, _ := io.ReadAll(resp.Body)
39 42
40 fmt.Println(string(body))
41
42 form_str := get_form_from_request_body(body) 43 form_str := get_form_from_request_body(body)
43 form_values := parse_form(form_str) 44 form_values := parse_form(form_str)
44 form_values["ctl01$sessionCode"][0] = attendance_code 45 form_values["ctl01$sessionCode"][0] = attendance_code
45 46
46 //fmt.Println(form_str)
47 //fmt.Println(form_values)
48
49 resp, _ = client.PostForm(link_url, form_values) 47 resp, _ = client.PostForm(link_url, form_values)
50 body, _ = io.ReadAll(resp.Body) 48 body, _ = io.ReadAll(resp.Body)
51 49
52 fmt.Println(string(body))
53 fmt.Println(resp)
54
55 if strings.Index(string(body), "ctl01_errorMessage") != -1 { 50 if strings.Index(string(body), "ctl01_errorMessage") != -1 {
56 errormsg_start := strings.Index(string(body), "ctl01_errorMessage") 51 errormsg_start := strings.Index(string(body), "ctl01_errorMessage")
57 errormsg_start += strings.Index(string(body)[errormsg_start:], "Text\">") 52 errormsg_start += strings.Index(string(body)[errormsg_start:], "Text\">")