librus-apix

Web Scraper for Librus Synergia


Keywords
librus, scraper, api, synergia, librus-api, librus-synergia
License
MIT
Install
pip install librus-apix==0.6.13

Documentation

librus-apix logo

Librus Synergia web scraper.

Installation

pip install librus-apix

Quick Start

Getting the Token

from librus_apix.get_token import get_token

token = get_token("Username", "Password")

Save and Load token

from librus_apix.get_token import get_token, Token

token = get_token("Username", "Password")

token_key = token.API_Key
# you can store this key and later load it into Token class like this:
token = Token(token_key)

Getting the Math grades

from librus_apix.grades import get_grades

grades, average_grades, descriptive_grades = get_grades(token)

for semester in grades:
  for mark in semester["Mathematics"]:
      print(mark.grade)
for semester in descriptive_grades:
  for mark in semester["Emotional development"]:
      print(mark.grade)

Getting the Announcements

from librus_apix.announcements import get_announcements

announcements = get_announcements(token)

for a in announcements:
  print(a.description)

Getting the attendance

from librus_apix.attendance import get_attendance

first_semester, second_semester = get_attendance(token)

for attendance in first_semester:
  print(attendance.symbol, attendance.date)

Getting the attendance frequency

from librus_apix.attendance import get_attendance_frequency

first, second, overall = get_attendance_frequency(token)
print(f"{first*100}%")

Getting the Homework

from librus_apix.homework import get_homework, homework_detail

# date from-to up to 1 month 
date_from = '2023-03-02'
date_to = '2023-03-30'

homework = get_homework(token, date_from, date_to)

for h in homework:
  print(h.lesson, h.completion_date)
  href = h.href
  details = homework_detail(token, href)
  print(details)

Getting the Messages

from librus_apix.messages import get_recieved, message_content

messages = get_recieved(token, page=1)
for message in messages:
  print(message.title)
  href = message.href
  print(message_content(token, href))

Getting the Schedule

from librus_apix.schedule import get_schedule, schedule_detail
month = '2'
year = '2023'
schedule = get_schedule(token, month, year)
for day in schedule:
  for event in schedule[day]:
    print(event.title)
    prefix, href = event.href.split('/')
    details = schedule_detail(token, prefix, href)
    print(details)

Getting the Timetable

from datetime import datetime
from librus_apix.timetable import get_timetable

monday_date = '2023-04-3'
monday_datetime = datetime.strptime(monday_date, '%Y-%m-%d')
timetable = get_timetable(token, monday_datetime)
for weekday in timetable:
  for period in timetable[weekday]:
    print(period.subject, period.teacher_and_classroom)

Getting the lucky number

from librus_apix.student_information import student_information

info = student_information(token)
print(info.lucky_number)

Adding a proxy

# Proxy can be added with
token = get_token(u, p, proxy={"https": "http://my-proxy.xyz"})
# or
token.proxy = {"https": "http://my-proxy.xyz"}
# or
token = Token(token_key, proxy={"https": "http://my-proxy.xyz"})

Working on the Project

git clone https://github.com/RustySnek/librus-apix
cd librus-apix
python -m venv venv
source ./venv/bin/activate
pip install requirements.txt
# Installing library with editable flag
sed -i "s/{{VERSION_PLACEHOLDER}}/1.0.0-dev/g" setup.cfg
pip install -e .