Skip to main content

Python library for using gdz.ru API

Project description

gdz-ru-py

License Python Version PyPI - Version

Python library for using gdz.ru API


Table of Contents

Installation

Stable version

$ pip install gdzru --upgrade

Latest version

$ pip install https://github.com/OctoDiary/OctoDiary-py/archive/main.zip --upgrade

Using

from gdzru import AsyncAPI, SyncAPI

async def amain():
    """
    Asynchronous using GDZ.ru API
    """
    api = AsyncAPI()

    # Get info for classes, subjects, books, etc.
    info = await api.get_books_list()

    # Get info for one book
    book_info = await api.get_book(info.books[0].url)

    # Print book authors, title, etc.
    print("Title:", book_info.book.title)
    print("Authors:", ", ".join(book_info.book.authors))
    print("Year:", book_info.book.year)
    print("Publisher:", book_info.book.publisher)

    # Get get first task of first book structure
    task_info = await api.get_task(book.structure[0].tasks[0].url)
    print("Task title:", task_info.task.title)


    # Get images of task
    images: list[bytes] = [
        await api.get_image(image.url)
        for image in task_info.task.editions[0].images
    ]

def main():
    """
    Synchronous using GDZ.ru API
    """
    api = SyncAPI()

    # Get info for classes, subjects, books, etc.
    info = api.get_books_list()

    # Get info for one book
    book_info = api.get_book(info.books[0].url)

    # Print book authors, title, etc.
    print("Title:", book_info.book.title)
    print("Authors:", ", ".join(book_info.book.authors))
    print("Year:", book_info.book.year)
    print("Publisher:", book_info.book.publisher)

    # Get get first task of first book structure
    task_info = api.get_task(book.structure[0].tasks[0].url)

    # Print task title
    print("Task title:", task_info.task.title)

    # Get images of task
    images: list[bytes] = [
        api.get_image(image.url)
        for image in task_info.task.editions[0].images
    ]

License

gdzru is distributed under the terms of the MIT license.

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

gdzru-1.0.0.tar.gz (6.0 kB view hashes)

Uploaded Source

Built Distribution

gdzru-1.0.0-py3-none-any.whl (8.8 kB view hashes)

Uploaded Python 3

Supported by

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