package parse

import "github.com/ditsuke/go-amizone/amizone/internal/parse"

Index

Constants

const (
	ErrFailedToParse    = "failed to parse"
	ErrFailedToParseDOM = ErrFailedToParse + " DOM"
	ErrNotLoggedIn      = ErrFailedToParse + ": not logged in"
)

Errors

const ExamTitleUnknown = "Unknown Exam"

Functions

func Attendance

func Attendance(body io.Reader) (models.AttendanceRecords, error)

Attendance attempts to parse course attendance information from the Amizone home page into a models.AttendanceRecords instance.

func ClassSchedule

func ClassSchedule(body io.Reader) (models.ClassSchedule, error)

ClassSchedule attempts to parse the response of the Amizone diary events API endpoint into a models.ClassSchedule instance.

func CleanString

func CleanString(s string, set ...rune) string

CleanString trims off whitespace and additional runes passed.

func Courses

func Courses(body io.Reader) (models.Courses, error)

Courses parses the Amizone courses page.

func ExaminationResult

func ExaminationResult(body io.Reader) (*models.ExamResultRecords, error)

ExaminationResult attempts to parse exam result information from the Amizone Examination Results page into a models.ExaminationResultRecords instance.

func ExaminationSchedule

func ExaminationSchedule(body io.Reader) (*models.ExaminationSchedule, error)

ExaminationSchedule attempts to parse a page into a models.ExaminationSchedule model. This function expects the Amizone "Examination Schedule" page, parsable into an HTML document.

func FacultyFeedback

func FacultyFeedback(body io.Reader) (models.FacultyFeedbackSpecs, error)

func IsLoggedIn

func IsLoggedIn(body io.Reader) bool

IsLoggedIn attempts to determine whether a response body indicates an authenticated session. To achieve this, this function will first attempt to parse the body as an HTML document, failing to do which is assumed to indicate an authenticated session because Amizone seems to redirect unauthenticated requests from all endpoints to the login page. If the body is parsed into a HTMl document, this function will attempt to find the login form; failing to find the login form is assumed to indicate an authenticated session.

func IsLoggedInDOM

func IsLoggedInDOM(doc *goquery.Document) bool

func Profile

func Profile(body io.Reader) (*models.Profile, error)

func Semesters

func Semesters(body io.Reader) (models.SemesterList, error)

Semesters returns the number of ongoing or passed semesters from the Amizone courses page.

func UnescapeUnicode

func UnescapeUnicode(s string) string

UnescapeUnicode unescapes unicode characters in a string. Ref: https://groups.google.com/g/golang-nuts/c/KO1yubIbKpU/m/ue_EU8dcBQAJ

func VerificationToken

func VerificationToken(body io.Reader) string

func VerificationTokenFromDom

func VerificationTokenFromDom(dom *goquery.Document) string

func WifiMacInfo

func WifiMacInfo(body io.Reader) (*models.WifiMacInfo, error)

Source Files

attendance.go class_schedule.go courses.go examination_result.go examination_schedule.go faculty_feedback.go logged_in.go parse.go profile.go sem_count.go verification_token.go wifi.go

Version
v0.8.0 (latest)
Published
Jun 9, 2023
Platform
linux/amd64
Imports
18 packages
Last checked
1 day ago

Tools for package owners.