mobiapi

package module
v0.0.0-...-ee0b959 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 23, 2023 License: GPL-3.0 Imports: 9 Imported by: 1

README

MobiAPI

WIP scraping library for Polish e-register mobiDziennik made in Go

Examples

Check out examples/ folder for individual examples, however if you want to see reference implementation, check out my abomination of a desktop app - mobiNG (hehe funny name).

Development

For developing MobiAPI you'll first of all need access to mobiDziennik, a web browser and a basic understanding of Go and probably how various web technologies work and a proxy for intercepting network trafic. I can recommend ZAP since it's what I've been using but it's cross-platform and open source but you can use anything. MobiAPI type already has a function for connecting to a proxy server you can use.

Documentation

Index

Constants

View Source
const (
	MessageSent     = 1
	MessageReceived = 2
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Grade

type Grade struct {
	Description string
	Category    string
	Value       string
	Subject     string
	Semester    int
}

type MessageContent

type MessageContent struct {
	Info       MessageInfo
	Content    string
	RawContent string
	Downloads  map[string]string
}

type MessageInfo

type MessageInfo struct {
	Kind   int
	Title  string
	Author string
	ID     int
	Read   bool
}

type MobiAPI

type MobiAPI struct {
	OnLostConnection func()
	// contains filtered or unexported fields
}

func New

func New(domain string) (*MobiAPI, error)

Create new instance of MobiAPI.

func (*MobiAPI) ExtendSession

func (api *MobiAPI) ExtendSession() error

Does a random request to extend session

func (*MobiAPI) GetGrades

func (api *MobiAPI) GetGrades(semester int) (map[string][]Grade, error)

func (*MobiAPI) GetMessageContent

func (api *MobiAPI) GetMessageContent(message MessageInfo) (MessageContent, error)

Read Received Message from MessageInfo into MessageContent.

func (*MobiAPI) GetName

func (api *MobiAPI) GetName() string

Get user's name

func (*MobiAPI) GetReceivedMessages

func (api *MobiAPI) GetReceivedMessages(firstpage bool) ([]MessageInfo, error)

Scrapes and returns message IDs and titles from first or every subsequent page in the form of MessageInfo. Use GetMessageContent() with MessageInfo to read it.

func (*MobiAPI) GetSentMessages

func (api *MobiAPI) GetSentMessages(firstpage bool) ([]MessageInfo, error)

Scrapes and returns message IDs and titles from first or every subsequent page in the form of MessageInfo. Use GetMessageContent() with MessageInfo to read it.

func (*MobiAPI) GetUID

func (api *MobiAPI) GetUID() int

Get UID

func (*MobiAPI) LoggedIn

func (api *MobiAPI) LoggedIn(noprecache bool) bool

Check if still signed in

func (*MobiAPI) Logout

func (api *MobiAPI) Logout() (bool, error)

Logout from mobiDziennik

func (*MobiAPI) PasswordAuth

func (api *MobiAPI) PasswordAuth(login, password string) (bool, error)

Authenticate with password.

func (*MobiAPI) SearchMessages

func (api *MobiAPI) SearchMessages(phrase string) ([]MessageInfo, error)

Searches messages using MobiDziennik's built-in search feature.

func (*MobiAPI) SetDomain

func (api *MobiAPI) SetDomain(domain string) error

Check if domain is accessible and if it is, use it. If the domain doesn't contain any dots it will be treated as a mobidziennik.pl subdomain.

func (*MobiAPI) SetupProxy

func (api *MobiAPI) SetupProxy(proxyurl string, noverifytls bool) error

Set proxy server to use and whenever to allow invalid TLS certificates. Useful for development

func (*MobiAPI) TokenAuth

func (api *MobiAPI) TokenAuth(token string) (bool, error)

Authenticate with provided token from cookie

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL