# gdz API
[](https://opensource.org/licenses/MIT)
[](https://www.python.org/downloads/release/python-391/)
[](https://pypi.org/project/gdzapi)
-----
**Table of Contents**
- [Installation](#installation)
- [Usage](#usage)
- [License](#license)
- [API Reference](#api-reference)
-----
An asynchronous Python library for accessing GDZ (Готовые домашние задания) resources.
-----
## Installation
### Stable version
```bash
pip install gdzapi --upgrade
```
-----
## Usage
### Synchronous Usage
Here's a basic example of how to use the synchronous GDZ class:
```python
# First type of usage
from gdzapi import GDZ
gdz = GDZ()
for subject in gdz.subjects:
if subject.name == "Биология":
book = gdz.get_books(subject)[0]
print(f"Book: {book.name}")
pages = gdz.get_pages(book.url)
print(f"Number of pages: {len(pages)}")
if pages:
solutions = gdz.get_gdz(pages[0].url)
image_url = solutions[0].image_src
print(image_url)
#--------------------------------------------------------------
# Second type of usage
from gdzapi import GDZ
gdz = GDZ()
subjects = gdz.subjects
for subject in subjects:
if subject.name == "Биология":
book = subject.books[0]
print(f"Book: {book.name}")
page = book.pages[0]
if page:
solutions = page.solutions
image_url = solutions[0].image_src
print(image_url)
```
-----
### Asynchronous Usage
Here's how to use the asynchronous AsyncGDZ class:
```python
# First type of usage
import asyncio
from gdzapi import AsyncGDZ
async def main():
async with AsyncGDZ() as gdz:
subjects = await gdz.subjects
for subject in subjects:
if subject.name == "Биология":
books = await gdz.get_books(subject)
if books:
book = books[0]
print(f"Book: {book.name}")
pages = await gdz.get_pages(book.url)
print(f"Number of pages: {len(pages)}")
if pages:
solutions = await gdz.get_gdz(pages[0].url)
print(solutions[0].image_src)
if __name__ == "__main__":
asyncio.run(main())
#--------------------------------------------------------------
# Second type of usage
import asyncio
from gdzapi import AsyncGDZ
async def main():
async with AsyncGDZ() as gdz:
subjects = await gdz.subjects
for subject in subjects:
if subject.name == "Биология":
books = await subject.books
if books:
book = books[0]
print(f"Book: {book.name}")
pages = await book.pages
if pages:
solutions = await pages[0].solutions
print(solutions[0].image_src)
if __name__ == "__main__":
asyncio.run(main())
```
## Euroki example
```python
from gdzapi import Euroki
e = Euroki()
books = e.search_books("Биология 10 класс")
for book in books:
if "Каменский" in book.authors:
downloadable_images = []
for i in book.pages:
for j in i.solutions:
downloadable_images.append(j.image_src)
print(downloadable_images)
```
## MegaResheba example
```python
from gdzapi import MegaResheba
m = MegaResheba()
for s in m.subjects:
if s.name == "История":
try:
print(s.books[0].pages[0].solutions[0].image_src)
except:
# This is means that there are no solutions
print("No solutions")
```
-----
## API Reference
### GDZ/Euroki/MegaResheba Class
``classes``: List of available classes
``subjects``: List of available subjects
``get_books(subject: Subject) -> List[Book]:`` Get books for a subject
``get_pages(url: str) -> List[Page]:`` Get pages for a given URL
``get_gdz(url: str) -> List[Solution]:`` Get solutions for a given URL
``search_books(query: str) -> List[Book]:`` Search books for a given query
-----
### AsyncGDZ Class
``classes``: Asynchronous property returning list of available classes
``subjects``: Asynchronous property returning list of available subjects
``get_books(subject: Subject) -> List[Book]:`` Asynchronous method to get books for a subject
``get_pages(url: str) -> List[Page]:`` Asynchronous method to get pages for a given URL
``get_gdz(url: str) -> List[Solution]:`` Asynchronous method to get solutions for a given URL
``search_books(query: str) -> List[Book]:`` Asynchronous method to search books for a given query
## License
`gdzAPI` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.
Raw data
{
"_id": null,
"home_page": "https://github.com/maybewewill/gdzAPI",
"name": "gdzapi",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.11",
"maintainer_email": null,
"keywords": null,
"author": "maybewewill",
"author_email": "qq238373@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/7b/e4/a484a716b04dedc32522449be0d15781a51fad9a7d55e6a48d81aaf91925/gdzapi-0.2.0.tar.gz",
"platform": null,
"description": "# gdz API\r\n[](https://opensource.org/licenses/MIT)\r\n[](https://www.python.org/downloads/release/python-391/)\r\n[](https://pypi.org/project/gdzapi)\r\n-----\r\n**Table of Contents**\r\n\r\n- [Installation](#installation)\r\n- [Usage](#usage)\r\n- [License](#license)\r\n- [API Reference](#api-reference)\r\n-----\r\nAn asynchronous Python library for accessing GDZ (\u0413\u043e\u0442\u043e\u0432\u044b\u0435 \u0434\u043e\u043c\u0430\u0448\u043d\u0438\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u044f) resources.\r\n\r\n-----\r\n## Installation\r\n### Stable version\r\n```bash\r\npip install gdzapi --upgrade\r\n```\r\n-----\r\n## Usage\r\n### Synchronous Usage\r\nHere's a basic example of how to use the synchronous GDZ class:\r\n\r\n```python\r\n# First type of usage\r\nfrom gdzapi import GDZ\r\n\r\ngdz = GDZ()\r\n\r\nfor subject in gdz.subjects:\r\n if subject.name == \"\u0411\u0438\u043e\u043b\u043e\u0433\u0438\u044f\":\r\n book = gdz.get_books(subject)[0]\r\n print(f\"Book: {book.name}\")\r\n\r\n pages = gdz.get_pages(book.url)\r\n print(f\"Number of pages: {len(pages)}\")\r\n\r\n if pages:\r\n solutions = gdz.get_gdz(pages[0].url)\r\n image_url = solutions[0].image_src\r\n print(image_url)\r\n\r\n#--------------------------------------------------------------\r\n \r\n# Second type of usage\r\nfrom gdzapi import GDZ\r\n\r\ngdz = GDZ()\r\n\r\nsubjects = gdz.subjects\r\nfor subject in subjects:\r\n if subject.name == \"\u0411\u0438\u043e\u043b\u043e\u0433\u0438\u044f\":\r\n book = subject.books[0]\r\n print(f\"Book: {book.name}\")\r\n \r\n page = book.pages[0]\r\n \r\n if page:\r\n solutions = page.solutions\r\n image_url = solutions[0].image_src\r\n print(image_url)\r\n```\r\n-----\r\n### Asynchronous Usage\r\nHere's how to use the asynchronous AsyncGDZ class:\r\n\r\n```python\r\n# First type of usage\r\nimport asyncio\r\nfrom gdzapi import AsyncGDZ\r\n\r\nasync def main():\r\n async with AsyncGDZ() as gdz:\r\n subjects = await gdz.subjects\r\n for subject in subjects:\r\n if subject.name == \"\u0411\u0438\u043e\u043b\u043e\u0433\u0438\u044f\":\r\n books = await gdz.get_books(subject)\r\n if books:\r\n book = books[0]\r\n print(f\"Book: {book.name}\")\r\n\r\n pages = await gdz.get_pages(book.url)\r\n print(f\"Number of pages: {len(pages)}\")\r\n\r\n if pages:\r\n solutions = await gdz.get_gdz(pages[0].url)\r\n print(solutions[0].image_src)\r\n\r\nif __name__ == \"__main__\":\r\n asyncio.run(main())\r\n\r\n#--------------------------------------------------------------\r\n \r\n# Second type of usage\r\nimport asyncio\r\nfrom gdzapi import AsyncGDZ\r\n\r\nasync def main():\r\n async with AsyncGDZ() as gdz:\r\n subjects = await gdz.subjects\r\n for subject in subjects:\r\n if subject.name == \"\u0411\u0438\u043e\u043b\u043e\u0433\u0438\u044f\":\r\n books = await subject.books\r\n if books:\r\n book = books[0]\r\n print(f\"Book: {book.name}\")\r\n \r\n pages = await book.pages\r\n if pages:\r\n solutions = await pages[0].solutions\r\n print(solutions[0].image_src)\r\n\r\nif __name__ == \"__main__\":\r\n asyncio.run(main())\r\n```\r\n## Euroki example\r\n```python\r\n\r\nfrom gdzapi import Euroki\r\n\r\ne = Euroki()\r\nbooks = e.search_books(\"\u0411\u0438\u043e\u043b\u043e\u0433\u0438\u044f 10 \u043a\u043b\u0430\u0441\u0441\")\r\nfor book in books:\r\n if \"\u041a\u0430\u043c\u0435\u043d\u0441\u043a\u0438\u0439\" in book.authors:\r\n downloadable_images = []\r\n for i in book.pages:\r\n for j in i.solutions:\r\n downloadable_images.append(j.image_src)\r\n print(downloadable_images)\r\n```\r\n## MegaResheba example\r\n```python\r\nfrom gdzapi import MegaResheba\r\n\r\nm = MegaResheba()\r\nfor s in m.subjects:\r\n if s.name == \"\u0418\u0441\u0442\u043e\u0440\u0438\u044f\":\r\n try:\r\n print(s.books[0].pages[0].solutions[0].image_src)\r\n except:\r\n # This is means that there are no solutions\r\n print(\"No solutions\")\r\n```\r\n\r\n-----\r\n## API Reference\r\n\r\n\r\n### GDZ/Euroki/MegaResheba Class\r\n\r\n``classes``: List of available classes\r\n\r\n``subjects``: List of available subjects\r\n\r\n``get_books(subject: Subject) -> List[Book]:`` Get books for a subject\r\n\r\n``get_pages(url: str) -> List[Page]:`` Get pages for a given URL\r\n\r\n``get_gdz(url: str) -> List[Solution]:`` Get solutions for a given URL\r\n\r\n``search_books(query: str) -> List[Book]:`` Search books for a given query\r\n\r\n-----\r\n### AsyncGDZ Class\r\n\r\n``classes``: Asynchronous property returning list of available classes\r\n\r\n``subjects``: Asynchronous property returning list of available subjects\r\n\r\n``get_books(subject: Subject) -> List[Book]:`` Asynchronous method to get books for a subject\r\n\r\n``get_pages(url: str) -> List[Page]:`` Asynchronous method to get pages for a given URL\r\n\r\n``get_gdz(url: str) -> List[Solution]:`` Asynchronous method to get solutions for a given URL\r\n\r\n``search_books(query: str) -> List[Book]:`` Asynchronous method to search books for a given query\r\n\r\n## License\r\n\r\n`gdzAPI` is distributed under the terms of the [MIT](https://spdx.org/licenses/MIT.html) license.\r\n",
"bugtrack_url": null,
"license": null,
"summary": "Python library for parsing GDZ.ru (async and sync)",
"version": "0.2.0",
"project_urls": {
"Homepage": "https://github.com/maybewewill/gdzAPI"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "7be4a484a716b04dedc32522449be0d15781a51fad9a7d55e6a48d81aaf91925",
"md5": "4b1054210324b7d89261c2718a141db1",
"sha256": "17f535341d306225f8ded26e719bb4475789552de107ba0b3c9bd0f272ef23ca"
},
"downloads": -1,
"filename": "gdzapi-0.2.0.tar.gz",
"has_sig": false,
"md5_digest": "4b1054210324b7d89261c2718a141db1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.11",
"size": 8221,
"upload_time": "2024-09-11T13:34:36",
"upload_time_iso_8601": "2024-09-11T13:34:36.336173Z",
"url": "https://files.pythonhosted.org/packages/7b/e4/a484a716b04dedc32522449be0d15781a51fad9a7d55e6a48d81aaf91925/gdzapi-0.2.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-09-11 13:34:36",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "maybewewill",
"github_project": "gdzAPI",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "gdzapi"
}