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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file gdzru-1.0.0.tar.gz.

File metadata

  • Download URL: gdzru-1.0.0.tar.gz
  • Upload date:
  • Size: 6.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for gdzru-1.0.0.tar.gz
Algorithm Hash digest
SHA256 6fcfed6ab537ddbd6128638e036155c7135f5f582f2654212ffe06328f2d667d
MD5 5e91f57a1d847a77d59a9ad8444471bf
BLAKE2b-256 f9124cc1a26cd4e11a5f854532cde57dfe5098c3ed5f228e0e0049ee5a47cbef

See more details on using hashes here.

File details

Details for the file gdzru-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: gdzru-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 8.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.4

File hashes

Hashes for gdzru-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 eaf0650cb19c8231d5acf068e72ae395f9edb1006a1c5ebd4a468897d773384d
MD5 97ab20bb84b685749c730c6b0d694306
BLAKE2b-256 6e8f25723d067e91de8442a83970dd521a074e149a6d6bc09f90252d20066bf3

See more details on using hashes here.

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