kurwjan / lanisapi Goto Github PK
View Code? Open in Web Editor NEWAn unofficial python library for Lanis.
Home Page: https://lanisapi.readthedocs.io/
License: MIT License
An unofficial python library for Lanis.
Home Page: https://lanisapi.readthedocs.io/
License: MIT License
Is it unnecessary? Maybe but I also want to learn new stuff with this project so why not.
Hab wieder Bock mal auf Python und hab auch paar Ideen die dieses Projekt verbessern würde, aber müsste somit auch die komplette Struktur verändern. (villt. unnötig, aber egal)
Das wird wahrscheinlich nicht so schnell gehen, weil ich möchte auch nebenbei bei der Lanis-App weitermachen.
Mein Ziel ist es die gleichen Apps wie vorher zu unterstützen und den Rest kann man einfach selber erweitern.
Außerdem will ich Readme und Docs nicht mehr krankhaft in Englisch machen sondern einfach Deutsch.
Use Python generators for more performance and seems to be the preferred way in web scraping (see Scrapy).
lädt einen zusätzlichen Tag ... (unsere Schule hat immer 2 Tage einmal den aktuellen, dazu noch den nächsten Tag)
# Add 1 day to the date
tomorrow = date_obj + timedelta(days=1)
# Create the list with the date and tomorrow
date_list = [info["date"], tomorrow.strftime("%d.%m.%Y")]
for date_str in date_list:
print(f"Date: {date_str}")
data = {"ganzerPlan": "true", "tag": date_str}
As stated here the session is for 100min valid after the last request.
So when we call close()
we could save the session cookies (encrypted) and on the next authenticate()
we just load it.
Also add support for 30 days long sessions.
It uses the same URLs as the normal login but it additionally posts to https://start.schulportal.hessen.de/registerbrowser and saves the cookie SPH-AutoLogin
.
What to post is unknown.
close()
function ed600cfauthenticate()
function ed600cfRemove encryption because it's unnecessary.
Es wird "Mein Unterricht" nicht gefunden, weil es in implemented_apps "mein Unterricht" geschrieben wurde, aber dort "Mein Unterricht" stehen muss. (Wenn es geändert wurde, wird MeinUntericht gefunden.)
In https://github.com/kurwjan/LanisAPI/blob/master/src/lanisapi/authentication_functions.py in Zeile 54 gibt es eine Feste School ID.
This is a bit harder because the "Nachrichten" page has a 2-Level-Encryption.
Wenn die Schule auf Lanis keinen Vertretungsplan hat gibt es einen "list index out of range" error.
Vielleicht eine Prüfung auf Existenz einbauen. (Ich kann, wenn es gebraucht wird, auch die HTML schicken.)
File "***\Lib\site-packages\lanisapi\functions\substitution.py", line 84, in _get_substitution_info
date = re.findall(r"(\d\d.\d\d.\d\d\d\d)", html.html)[0]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range
Looks like an API exists for this page.
It is probably used by no one anymore but it still exists to be parsed!
Seems to be that no API exists.
Wenn es einen Task/Eintrag gibt ohne Titel gibt es einen Crash.
File "***\Lib\site-packages\lanisapi\functions\tasks.py", line 67, in _get_tasks
title = element.css_first("td:nth-child(2) > b:nth-child(1)").text()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'text'
Instead of
LanisClient("schoolid", ....)
You can use school name and location
LanisClient("schoolname", "location")
When you authenticate for the first time it parses this page to get all schools. (Probably in JSON format)
Also add a function to get all schools for the developer.
Für jedes Unterrichtsfach gibt es auch eine Detaillierte Seite, die mehr Informationen besitzt. Diese Seite könnte man auch einbauen, um eine Historie anzuzeigen.
https://start.schulportal.hessen.de/meinunterricht.php?a=sus_view&id=1234
Add CLI support using Typer.
Would be pretty useful for (bash) scripts or so.
Es wäre nützlich, wenn bei Kalendereinträgen auch steht von welchem Lehrer dieser erstellt wurde.
Dafür muss man den Wert von "Verantwortlich", der aus dem Json von Calendar kommt, mit der Lehrer ID verknüpfen.
An die IDs der Lehrer kommt man indem man alle Variationen von aa bis zz durchgeht. Dies wird bei der URL "https://start.schulportal.hessen.de/nachrichten.php?q={search}&page=1&a=searchRecipt" gemacht und gespeichert.
For example: sometimes I get a LoginPageRedirectError when using this lib normally.
This page has all courses, teachers (also has profile pics of them) and tests.
Of course it has no API,, thanks Lanis ):
The problem is that unread
doesn't exist?
Seems to be really random.
This contains current tasks, past tasks, teacher, when, room, presence and so forth.
I mean the current one isn't so helpful.
I ran the example code with my credentials and ended with this:
INFO - LanisClient Authenticated.
INFO - httpx HTTP Request: POST https://start.schulportal.hessen.de/vertretungsplan.php "HTTP/1.1 200 OK"
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
File /opt/conda/lib/python3.11/site-packages/lanisapi/functions/substitution.py:88, in _get_substitution_info()
87 try:
---> 88 date = re.findall(r"(\d\d\.\d\d\.\d\d\d\d)", date_element.text())[0]
89 except AttributeError as err:
AttributeError: 'NoneType' object has no attribute 'text'
...
File /opt/conda/lib/python3.11/site-packages/lanisapi/functions/substitution.py:94, in _get_substitution_info()
90 HTMLLogger.log_missing_element(
91 html.html, "get_substitution_info()", "/", "date"
92 )
93 msg = "Critical date element was not found, something is definitely wrong! Please file a bug with the html_logs.txt file."
---> 94 raise CriticalElementWasNotFoundError(msg) from err
96 LOGGER.info(f"Substitution info: Successfully got info. Notice is {bool(notice)}.")
98 return {"notice": notice, "date": date}
CriticalElementWasNotFoundError: Critical date element was not found, something is definitely wrong! Please file a bug with the html_logs.txt file.
This is the actual conent of the page:
I can see the text in the html_logs.txt
Let me know what help can look like
Add to the docs handy CSS selectors, links or something similar for every thing what you can scrape.
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.