From c411ee3447fca4389bff3d228a5a0068204f0dad Mon Sep 17 00:00:00 2001 From: Juan Roig Date: Tue, 31 Oct 2023 02:06:01 -0400 Subject: [PATCH] Form parsing done correctly --- go.sum | 0 main.go | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) create mode 100644 go.sum diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..e69de29 diff --git a/main.go b/main.go index eb88b8d..63b978f 100644 --- a/main.go +++ b/main.go @@ -5,6 +5,7 @@ import ( "fmt" "io" "net/http" + "net/url" "strings" ) @@ -49,6 +50,48 @@ func get_course_ids(canvas_courses []CanvasCourse) []uint64 { return courses } +// parseForm extracts form fields and values from the given HTML form string. +func parse_form(form_html string) url.Values { + form_values := make(url.Values) + inputs := strings.Split(form_html, "") + 7 form_html := body[form_start:form_end] - fmt.Println(string(form_html)) + form := string(form_html) + fmt.Println(form) + form_values := parse_form(form) + + fmt.Println("Form Values:") + for key, values := range form_values { + fmt.Printf("%s: %s\n", key, values) + } } /*