Skip to main content

Python library for scraping viggo assignments

Project description

Viggoscrape.py

Python library for scraping Viggo assignments by interacting with the Viggoscrape API.

The API is designed for danish users, and time will be adjusted to the CET timezone.

Quickstart

Syntax

Viggoscrape.py uses the following syntax:

  1. Provide subdomain, username and password on class initialization
  2. Provide optional parameters: date, grouping mode and API version after initialization
  3. Retrieve a list of assignments using the get_assignments method, or retrieve a dictionary of assignment attributes using the get_attributes method.

Usage example

Most of the time you'll want to do something like this:

from viggoscrape import Viggoscrape

v = Viggoscrape(
    subdomain="example-subdomain",
    username="viggouser@gmail.com",
    password="password123456"
) # initialization
v.date = "2021-03-14" # get assignments within 2 weeks of this date

print(v.get_assignments()) # get a list of dictionaries representing assignments

The output should look something like this:

[
    {
        "author": "14. mar 2021 11:09 by Teacher McTeacher",
        "date": "Monday 16. Mar",
        "description": "Read this and that blablabla, here are some links: https://github.com/nangurepo/ https://viggoscrape.xyz/",
        "subject": "History",
        "time": "10:45 - 11:30",
        "url": "https://subdomain-example.viggo.dk/Basic/HomeworkAndAssignment/Details/1234/#modal"
    },
    {
        "author": "17. mar 2021 18:09 by Other Teacher",
        "date": "Tuesday 20. Mar",
        "description": "Read page 170-200 of 'To kill a mockingbird'",
        "subject": "English",
        "time": "12:00 - 12:45",
        "url": "https://subdomain-example.viggo.dk/Basic/HomeworkAndAssignment/Details/5678/#modal"
    }
]

Swap out v.get_assignments() for v.get_attributes() and it'll look like this:

{
    "subject": ["History", "English"],
    "date": ["Monday 16. Mar", "Tuesday 20. Mar"],
    "description": ["Read this and that blablabla, here are some links: https://github.com/nangurepo/ https://viggoscrape.xyz/", "Read page 170-200 of 'To kill a mockingbird'"],
    "author": ["14. mar 2021 11:09 by Teacher McTeacher", "17. mar 2021 18:09 by Other Teacher"],
    "url": ["https://subdomain-example.viggo.dk/Basic/HomeworkAndAssignment/Details/1234/#modal", "https://subdomain-example.viggo.dk/Basic/HomeworkAndAssignment/Details/5678/#modal"]
}

This can be used for other purposes.

Do note that if you, for some reason, need to use v1 of the API, data will always be returned as a dictionary of attributes, with the addition of file names and urls. Version 1 of the API uses a more thorough scan, scraping each individual assignment page, carrying a huge sacrifice of efficiency.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

viggoscrape-2.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

viggoscrape-2.1.0-py3-none-any.whl (3.7 kB view details)

Uploaded Python 3

File details

Details for the file viggoscrape-2.1.0.tar.gz.

File metadata

  • Download URL: viggoscrape-2.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for viggoscrape-2.1.0.tar.gz
Algorithm Hash digest
SHA256 9cf3899fb0f39519473803c6cfdd92b64f2b3cfa439d580096cd4525d524b1d8
MD5 2e1f0c691f56f18132ccdd5fbe296252
BLAKE2b-256 4f92782639b2743fa2dfb9c756753bf0129e8ccb6ba0b2181c91bd525c3906ea

See more details on using hashes here.

File details

Details for the file viggoscrape-2.1.0-py3-none-any.whl.

File metadata

  • Download URL: viggoscrape-2.1.0-py3-none-any.whl
  • Upload date:
  • Size: 3.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.1

File hashes

Hashes for viggoscrape-2.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51acae86774abdbcf6aa4f434180caf6c161985246732b1699a6d5ce8eb2f91a
MD5 6ff4613ba27681d16efa5857fb1ba052
BLAKE2b-256 2890ce219b54b362f8179c334964a07f7c36d648238a2e52d57043601f82d5fe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page