Welcome to LectioScraper’s documentation!

_images/twitter_header_photo_2.png

LectioScraper is a python package for helping you scrape lectio.dk with ease. It uses requests for the actual scraping and beautifulsoup for parsing the html. Scraping lectio.dk can be a tedious task, as it requires so much different html elements to be parsed. and lectio is a big website so there are a lot of different pages to scrape. Here you have everything configured and all you need to do is to import lectioscraper and start scraping (see the whole documentation below).

Getting help

If you have any problems with the documentation or with the code, please feel free to contact me on my email, discord or open an issue on github. (see below).

e-mail: emil@tovborg-jensen.dk
discord: Tovborg#7914
github: Lectioscraper github

Quick start

You can install lectioscraper with pip:

pip install lectioscraper

and for installing a specific version using pip:

pip install lectioscraper==version

After installing lectioscraper you need to import the Lectio class and create an instance of the class with your login details

import lectioscraper

client = lectioscraper.Lectio(username, password, schoolId)

# after importing you can start scraping with the client object, see below for all functions

# Example:
# Scrape all classes for the current week
client.getSchedule(to_json=True)

When initializing the client you can pass the following arguments: username, password, and a so called schoolId that is found by going to your school’s page on lectio.dk and looking at the url.

Example:

https://www.lectio.dk/lectio/59/default.aspx

here the schoolId is 59, the schoolid will always be after /lectio/

Usage

lectioscraper.Lectio.__init__(self, Username, Password, SchoolId, user_type)

Initializes the class with the username, password and school id. # noqa: E501 Init is not to be used directly, but is used when you create an instance of the class.

Parameters
  • Username (str) – The username of the student.

  • Password (str) – The password of the student.

  • SchoolId (str) – The school id of the student.

Returns

Will return an error if the username, password or school id is not provided or if login fails.

lectioscraper.Lectio.addToGoogleCalendar(self, CalendarID, user_type, weeks)

Adds the schedule for the current week to a Google Calendar. Accesses your calendar using OAuth2.0.

Parameters
  • CalendarID (str) – The ID of the calendar you want to add the schedule to.

  • user_type (str) – The type of user, either ‘elev’ or ‘laerer’.

  • weeks (int) – The number of weeks you want to add to the calendar. (starting from the current week)

Returns

Adds the schedule for the current week to a Google Calendar.

lectioscraper.Lectio.getAbsence(self, written_assignments, to_json)

getAbsence gets the absence for the student for the whole year. If writing is true, the function will also scrape your absence for written assignments. If to_json is true, the absence will be saved to a json file called absence.json. # noqa: E501

Parameters
  • written_assignments (bool) – if true, the absence for written assignments will be scraped.

  • to_json (bool) – if true, the absence will be saved to a json file called absence.json

Returns

returns the absence for the student in different classes for the whole year.

lectioscraper.Lectio.getAllHomework(self, to_json, print_to_console)

getAllHomework scrapes all the homework in the ‘lektier’ tab, currently there are no filters but scrapes all the homework for all classes, basically scrapes all the homework data that there is on the tab. # noqa: E501

Parameters
  • to_json (bool) – if true, the homework will be saved to a json file called homework.json.

  • print_to_console (bool) – if true, the homework will be printed to the console.

Returns

returns all the homework in the ‘lektier’ either as a json file or as a dictionary.

lectioscraper.Lectio.getAssignments(self, to_json=False, team='alle hold', status='alle status', fravaer='', karakter='')

getAssignments scrapes all your current assignments, this function actually has filters implemented so you can filter the assignments you want to see. Make sure to use the correct filters, otherwise you will get all the assignments. # noqa: E501

Parameters
  • to_json – if true, the assignments will be saved to a json file called assignments.json.

  • team – the team you want to filter the assignments by. Example: 1g/3 EnB (english with team 1g/3), the filters will be updated soon as it’s complicated atm.

  • status – the status you want to filter the assignments by. Example: Venter, Afleveret, Mangler

  • fravaer – the absence you want to filter the assignments by. Example: 100% fravær, 50% fravær, 0% fravær

  • karakter – the grade you want to filter the assignments by. Example: 12, 10, 7, 4, 02, 00, -3

Returns

returns all the assignments in the ‘afleveringer’ either as a json file or as a dictionary.

lectioscraper.Lectio.getSchedule(self, to_json, print_to_console=False)

getSchedule gets the schedule for the current week. Currently only works for the current week. # noqa: E501

Parameters
  • to_json (bool) – If true, the schedule will be saved to a json file.

  • print_to_console (bool) – If true, the schedule will be printed to the console.

Returns

if to_json is true, the schedule will be saved to a json file. If to_json is false, the schedule will be returned. If print_to_console is true, the schedule will be printed to the console.

lectioscraper.Lectio.getTodaysSchedule(self, to_json=False)

Returns the schedule for the current day, the current day is found using the datetime module, working on choosing the next day if the current school day is over. # noqa: E501

Parameters

to_json – If true, the schedule will be saved to a json file.

Returns

The schedule for the current day.

lectioscraper.Lectio.getUnreadMessages(self, to_json=False, get_content=False)

Returns the unread messages for the current user. # noqa: E501

Parameters
  • to_json – If true, the messages will be saved to a json file.

  • get_content – If true, the content of the messages will be returned aka the message body.

Returns

Returns the unread messages for the current user, if get_content is true, the message body will be returned too

Authors

Lectioscraper is developed and maintained by Emil Tovborg-Jensen.

License

lectioscraper is licensed under the GNU General Public License v3.0. You are free to modify and distribute as long as you give credit to the original author.

You can find the full license text either in the LICENSE file or on the following link: