From 89c2e2b38ee57f40217db83fb34e014102b0fb49 Mon Sep 17 00:00:00 2001 From: Juan Roig Date: Tue, 7 Nov 2023 00:21:48 -0500 Subject: reorganize functions to aplus-related and canvas-related. --- aplus.go | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) create mode 100644 aplus.go (limited to 'aplus.go') diff --git a/aplus.go b/aplus.go new file mode 100644 index 0000000..e2ec53b --- /dev/null +++ b/aplus.go @@ -0,0 +1,76 @@ +package main + +import ( + "encoding/json" + "fmt" + "io" + "net/http" + "net/url" + "strings" +) + +func get_aplus(token string, link string, client http.Client) string { + resp, err := client.Get(link) + + if err != nil { + fmt.Println("Error performing GET request to initial link.") + } + defer resp.Body.Close() + body, _ := io.ReadAll(resp.Body) + + var aplus Aplus + json.Unmarshal(body, &aplus) + + return aplus.URL +} + +func get_form_from_request_body(req_body []byte) string { + body_str := string(req_body) + form_start := strings.Index(body_str, "") + 7 + form_html := req_body[form_start:form_end] + + return string(form_html) +} + +// parse_form 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, "