Package: poethu
poethupoethu is a simple Python library that makes easy to access data frompoet.huTo access the API first you need toregisteron the site.Installation (pypi)pipinstallpoethuHow to install?First you need to install Python, if it is not installed it will won't work.Download Python# Ubuntu / Debian$sudoaptinstallpython# Fedora$sudodnfinstallpythonDownload required packages:$pipinstallrequestsHow to use?Using poethu is very easy.
First you need to register to the site to get the key.
You can do ithere.
After you succesfully registered you can get your keyhereUsage:Note: the synonyms and poems returns as a list If you want more than 1 synonyms or poems.importpoethupoet=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 synonymprint(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 synonymprint(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)foriinrange(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 APIhereExample usage:Synonyms:importpoethupoet=poethu.API(username="your_username",password="your_key")synonyms=poet.get_szinonima(word="Helló",order="asc",max=5)foriinrange(len(synonyms)):synonym=synonyms[i]print(f"{i}:{synonym}")Output:0: üdv
1: szia
2: cső
3: szervusz
4: hahóPoems:importpoethupoet=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)foriinrange(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