Skip to content
This repository was archived by the owner on Dec 11, 2021. It is now read-only.

Methods

CarelessInternet edited this page Nov 12, 2021 · 7 revisions

Public Methods

Public methods which anyone can access. All public methods are promises.

Initialization

Create a new instance of the SchoolSoft class. You need a chromium executable. This prepares everything before login.

Parameters

  • school: string: The name of the school. This can be found as the first part of the path, right after the first / when in SchoolSoft.
  • path?: string: The path to the chromium executable. This is optional. The default value is /usr/bin/chromium-browser, but you may change it to whatever you want, as long as it leads to the correct chromium executable.

Response

Returns the SchoolSoft class.

Examples

CommonJS

const SchoolSoft = require('schoolsoft-scraper').default;
// or
const { default: SchoolSoft } = require('schoolsoft-scraper');

const school = new SchoolSoft('school');
// or
const school = new SchoolSoft('school', '/path/to/chromium-executable');

ES6 Import/Typescript

import SchoolSoft from 'schoolsoft-scraper';

const school = new SchoolSoft('school');
// or
const school = new SchoolSoft('school', '/path/to/chromium-executable');

<SchoolSoft>.login(username, password)

Logs into SchoolSoft. This is required before fetching any data.

Parameters

  • username: string: The student's username.
  • password: string: The student's password.

Response

Returns the redirected URL on success, throws an error on failure.

Examples

school.login('sample', 'text')
.then(url => console.log('URL', url))
.catch(console.error);

<SchoolSoft>.getLunchMenu(week?)

Gets the lunch menu from SchoolSoft.

Parameters

  • week?: number: Optionally include the week that you want to get the lunch menu for.

Response

Returns the LunchMenu interface on success, throws an error on failure.

Examples

school.getLunchMenu()
.then(console.log)
.catch(console.error)
// or
school.getLunchMenu(40/*between 1 and 52*/)
.then(console.log)
.catch(console.error)

<SchoolSoft>.getNews()

Gets the current news from SchoolSoft.

Parameters

None.

Response

Returns the News interface on success, throws error on failure.

Examples

school.getNews()
.then(console.log)
.catch(console.error)

<SchoolSoft>.getAssignments()

Gets the upcoming and old assignments from SchoolSoft.

Parameters

None.

Response

Returns the Assignments interface on success, throws error on failure.

Examples

school.getAssignments()
.then(console.log)
.catch(console.error);

<SchoolSoft>.getResults()

Gets new and old assignment results from SchoolSoft.

Parameters

None.

Response

Returns the Results interface on success, throw error on failure.

Examples

school.getResults()
.then(console.log)
.catch(console.error);

<SchoolSoft>.getWeeklyPlanning()

Gets the weekly planning for each subject which has one from SchoolSoft.

Parameters

None.

Response

Returns the WeeklyPlanning interface on success, throws error on failure.

Examples

school.getWeeklyPlanning()
.then(console.log)
.catch(console.error)

<SchoolSoft>.logout()

Logs out of SchoolSoft.

Parameters

None.

Response

Returns true on successfully logging out, returns false or throws error on failure.

Examples

school.logout()
.then(bool => console.log('Logged out', bool))
.catch(console.error)

<SchoolSoft>.close()

Closes the chromium instance.

Parameters

None.

Response

Returns true on success, throws error on failure.

Examples

school.close()
.then(bool => console.log('Closed', bool))
.catch(console.error);

Private Methods

Private methods which only the class can access. All private methods are promises.

<SchoolSoft>.open()

Opens the chromium instance.

Parameters

None.

Response

Returns true on success, returns false on failure.

Examples

school.close();

<SchoolSoft>.isLoggedIn()

Checks to see if the user has successfully logged in via the <SchoolSoft>.login() method.

Parameters

None.

Response

Returns true if the user is logged in, throws error on not logged in.

Examples

school.isLoggedIn()
.then(bool => console.log('is logged in', bool))
.catch(console.error);

<SchoolSoft>.fetchLunchMenu()

Fetches the lunch menu from a page.

Parameters

None.

Response

Returns the LunchMenu interface on success, throws error on failure.

Examples

school.fetchLunchMenu()
.then(console.log)
.catch(console.error);