rustysnek / librus-apix Goto Github PK
View Code? Open in Web Editor NEWWeb scraper for Librus Synergia
License: GNU General Public License v3.0
Web scraper for Librus Synergia
License: GNU General Public License v3.0
Hi
Looks like the API was changes for in the more complexes example I've got grades problem reading using example scripts
Traceback (most recent call last):
File "/home/pg/apps/librus-apix/ania/grades_example.py", line 12, in
grades, semester_grades = get_grades(token, sort_by[0])
File "/home/pg/apps/librus-apix/librus_apix/grades.py", line 95, in get_grades
key, value = attr.split(': ')
ValueError: too many values to unpack (expected 2)
for the other kid looks pretty ok
Subject: Etyka
Subject: Język angielski
|6| - 2023-10-27
|5| - 2023-11-12
Subject: Religia
etc.
Hope that could help for the future software usage
thanks a lot
Hi,
BTW Great work with this library.
I'm trying to go with getting grades and I got an exception.
I'm sure the credentials are good, token is OK.
root@sandbox:~/librus-apix/examples# python3 grades_example.py Traceback (most recent call last): File "/root/librus-apix/examples/grades_example.py", line 12, in <module> grades, semester_grades = get_grades(token, sort_by[0]) File "/usr/local/lib/python3.9/dist-packages/librus_apix/grades.py", line 68, in get_grades tr = no_access_check( File "/usr/local/lib/python3.9/dist-packages/librus_apix/helpers.py", line 8, in no_access_check raise TokenError("Malformed or expired token.") librus_apix.exceptions.TokenError: Malformed or expired token.
Maybe html structure on the portal has been changed ?
When returning student information it will try to convert lucky_number to int, but if the school has lucky numbers disabled, the lucky number will show as ? which it will try to convert to int, resulting in ValueError: invalid literal for int() with base 10: '?'
Some schools may disable features like for example grade averages. Handle stuff like that so it doesn't break everything
I'm encountering a ValueError when calling some of the functions provided - more specifically, get_grades, get_attendance and get_schedule. I'm new to python so lmk if there's some sort of mistake on my side.
Code
from librus_apix.grades import get_grades
grades, average_grades = get_grades(token)
for mark in grades["Mathematics"]:
print(mark.grade)
Result
Traceback (most recent call last):
File "\main.py", line 8, in <module>
grades, average_grades = get_grades(token)
File "\AppData\Local\Programs\Python\Python310\lib\site-packages\librus_apix\grades.py", line 95, in get_grades
key, value = attr.split(': ')
ValueError: too many values to unpack (expected 2)
Code
from librus_apix.attendance import get_attendance
first_semester, second_semester = get_attendance(token)
for attendance in first_semester:
print(attendance.symbol, attendance.date)
Result
Traceback (most recent call last):
File "\main.py", line 16, in <module>
first_semester, second_semester = get_attendance(token)
File "\AppData\Local\Programs\Python\Python310\lib\site-packages\librus_apix\attendance.py", line 63, in get_attendance
_type, date, lesson, subject, teacher, hour, excursion, by = (
ValueError: not enough values to unpack (expected 8, got 7)
Code
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)
Result: Here the code successfully prints out one event from the schedule and then gets the error
Zastępstwo z Jan Kowalski na lekcji nr: 5 (Matematyka)
Traceback (most recent call last):
File "\main.py", line 38, in <module>
prefix, href = event.href.split('/')
ValueError: not enough values to unpack (expected 2, got 1)
Currently can't implement marking homework as done, due to POST: https://synergia.librus.pl/homework/markHomeworkAsDone
requiring studentID which isn't present anywhere.
In the README, the usage of get_grades is shown as follows:
from librus_apix.grades import get_grades
grades, average_grades = get_grades(token)
for mark in grades["Mathematics"]:
print(mark.grade)
Running this code results in TypeError: get_grades() missing 1 required positional argument: 'sort_by'
In the README file, functions are imported as follows:
from librus-apix.get_token import get_token
This causes an error, as it should look like so:
from librus_apix.get_token import get_token
(underscore instead of a hyphen)
message.title
returns the title displayed in the message list, not when the message is accessed. If the title is long then it ends with '...'.
Similar to #40
Some parts of the code had been written when I was still learning the basics and clearly are prone to random errors.
I'll work on it when I'll get some more free time.
Hi i have a problem with getting a timetable here is my code (from example)
from datetime import datetime
from librus_apix.timetable import get_timetable
from librus_apix.get_token import get_token
username = "login"
password = "pass"
token = get_token(username, password)
monday_date = '2023-10-09'
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)
and this is errors
Traceback (most recent call last):
File "/Users/uwmpr/Downloads/librus-apix-main/librus_apix/mojetesty.py", line 15, in <module>
timetable = get_timetable(token, monday_datetime)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/Users/uwmpr/Downloads/librus-apix-main/librus_apix/timetable.py", line 40, in get_timetable
lesson = periods[period].select(
~~~~~~~^^^^^^^^^^^^^
IndexError: list index out of range
Does anyone want to help me? thanks! And thanks for this code it helps me a lot with my own project.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.