You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
20 lines
708 B
20 lines
708 B
import requests
|
|
from termcolor import colored
|
|
|
|
def vypis_vsechny_prispevky():
|
|
url = "https://jsonplaceholder.typicode.com/posts"
|
|
print ("--- Načítám všechny příspěvky (Pole/Array) ---")
|
|
try:
|
|
response = requests.get(url)
|
|
response.raise_for_status()
|
|
data = response.json()
|
|
print(f"Typ stažených dat: {type(data)}")
|
|
print(f"celkový počet příspěvků: {colored(len(data),'yellow')}")
|
|
print("-"*30)
|
|
for prispevek in data[:10]:
|
|
print(f"ID: {prispevek['id']} | titulek: {colored(prispevek['title'],'cyan')}")
|
|
except Exception as e:
|
|
print(f"Chyba: {e}")
|
|
|
|
if __name__ == "__main__":
|
|
vypis_vsechny_prispevky()
|