An unofficial Python wrapper for the poet.hu API
Project description
poethu
poethu is a simple Python library that makes easy to access data from poet.hu
To access the API first you need to register on the site.
Installation (pypi)
pip install poethu
How to install?
First you need to install Python, if it is not installed it will won't work.
# Ubuntu / Debian
$ sudo apt install python
# Fedora
$ sudo dnf install python
Download required packages:
$ pip install requests
How to use?
Using poethu is very easy. First you need to register to the site to get the key. You can do it here. After you succesfully registered you can get your key here
Usage:
Note: the synonyms and poems returns as a list If you want more than 1 synonyms or poems.
import poethu
poet = poethu.API(username="your_username", password="your_key")
To get synonyms:
synonyms = poet.get_szinonima(word="Helló") # Change the word to anything else to get the word synonym
print(synonyms)
You can easily change the order, or change the max synonym:
synonyms = poet.get_szinonima(word="Helló", order="desc", max=10) # order by desc, and max 10 synonym
print(synonyms)
And for poems:
poems = poet.get_versek(category="kedvesemnek", max=2)
# The output is raw, so we need to format it.
# You only need to use loops when you want to get more poems than 1
# If you not, you can simply use title = poet.get_title(poems)
for i in range(len(poems)):
title = poet.get_title(poems)[i]
text = poet.get_text(poems)[i]
poem = poet.get_text(poems)[i]
author = poet.get_author(poems)[i]
category = poet.get_category(poems)[i]
favs = poet.get_favs(poems)[i]
id = poet.get_id(poems)[i]
url = poet.get_url(poems)[i]
print(f"Title: {title}")
print(f"Text: {text}")
print(f"Author: {author}")
print(f"Category: {category}")
print(f"Favs: {favs}")
print(f"ID: {id}")
print(f"url: {url}")
Poem params:
category
author
text
max (number)
order_by (id, ido, szerzo, kedvencek, veletlen)
order (asc, desc)
continue_from (number)
You can get more information about the API here
Example usage:
Synonyms:
import poethu
poet = poethu.API(username="your_username", password="your_key")
synonyms = poet.get_szinonima(word="Helló", order="asc", max=5)
for i in range(len(synonyms)):
synonym = synonyms[i]
print(f"{i}: {synonym}")
Output:
0: üdv
1: szia
2: cső
3: szervusz
4: hahó
Poems:
import poethu
poet = poethu.API(username="your_username", password="your_key")
poems = poet.get_versek(category="gyerekvers", max=2, order="desc", continue_from=20)
# The output is raw, so we need to format it.
# You only need to use loops when you want to get more poems than 1
# If you not, you can simply use title = poet.get_title(poems)
for i in range(len(poems)):
title = poet.get_title(poems)[i]
text = poet.get_text(poems)[i]
poem = poet.get_text(poems)[i]
author = poet.get_author(poems)[i]
category = poet.get_category(poems)[i]
favs = poet.get_favs(poems)[i]
id = poet.get_id(poems)[i]
url = poet.get_url(poems)[i]
print(f"Title: {title}")
print(f"Poem text: \n{text}")
print(f"Author: {author}")
print(f"Category: {category}")
print(f"Favs: {favs}")
print(f"ID: {id}")
print(f"URL: {url}")
Output:
Title: Farkas és a bárány
Poem text:
Én vagyok a farkas,
Fél tőlem a szarvas,
Ha prédára akadok,
Az erdőben maradok.
Az én nevem barika,
Barátom a Gabika,
Jaj, de félve lépkedek,
Ha erdőbe tévedek.
Author: Tóth Marianna (banattanc)
Category: Gyerekvers
Favs: 23
ID: 351818
URL: https://www.poet.hu/vers/351818
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file poethu-1.0.4.tar.gz.
File metadata
- Download URL: poethu-1.0.4.tar.gz
- Upload date:
- Size: 4.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
35981ce7a45990d33f4da0b7866c46bd9faf6d1b1a13861a3f22f959092e2182
|
|
| MD5 |
7e2a7be57a46b1f5a7d5295206bb0a68
|
|
| BLAKE2b-256 |
4dcba29f45291965b1b835f9e4120de717ac3d44dfa655c981e4d0d2810cafc8
|
File details
Details for the file poethu-1.0.4-py3-none-any.whl.
File metadata
- Download URL: poethu-1.0.4-py3-none-any.whl
- Upload date:
- Size: 4.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8e0384257cbcf05877c2d3e51d3290953149e0d693bbe7e3a3172e433d5d1437
|
|
| MD5 |
615e853378f63d7e7a541262a283233f
|
|
| BLAKE2b-256 |
a97645d5dc2721cf58537c8fe6a118961dac335894331e3485593fe2e70f329f
|