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.
23 lines
607 B
23 lines
607 B
import requests
|
|
from termcolor import colored
|
|
import time
|
|
|
|
def get_dad_joke():
|
|
print ("Nahodný dad džouk")
|
|
url = "https://icanhazdadjoke.com"
|
|
headers = {
|
|
"Accept":"application/json",
|
|
"User-Agent" : "Python example for programming lessons"
|
|
}
|
|
try:
|
|
response = requests.get(url,headers=headers)
|
|
response.raise_for_status()
|
|
data =response.json()
|
|
print(colored(f"\n{data["joke"]}\n","green"))
|
|
except Exception as e:
|
|
print(f"chyba:{e}")
|
|
|
|
if __name__ == "__main__":
|
|
for i in range(5):
|
|
get_dad_joke()
|
|
time.sleep(3)
|