diff options
| author | Juan Roig <jaroig@outlook.com> | 2023-11-14 22:42:25 -0500 |
|---|---|---|
| committer | Juan Roig <jaroig@outlook.com> | 2023-11-14 22:42:25 -0500 |
| commit | e28dc923074ff7445d23cb97a04233f6192a69be (patch) | |
| tree | 39a3076839b9d79e4e8dbce40280e8943abf11cc /aplus.go | |
| parent | 329f8dfe029025d591cf3e111dc842a7f4c2a43f (diff) | |
Add flags, update README
Diffstat (limited to 'aplus.go')
| -rw-r--r-- | aplus.go | 11 |
1 files changed, 3 insertions, 8 deletions
| @@ -12,6 +12,9 @@ import ( | |||
| 12 | 12 | ||
| 13 | func submit_code(course_code int, attendance_code string) { | 13 | func 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\">") |
