-
Notifications
You must be signed in to change notification settings - Fork 32
/
Copy pathjokes.py
41 lines (37 loc) · 1.03 KB
/
jokes.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#------randome joke functions using different APIs
import requests
import random
def geeks():
url = "https://geek-jokes.sameerkumar.website/api"
resp = requests.get(url)
resp.encoding = "utf-8"
data = resp.json()
return (data)
def chuck_norris():
url = "https://api.icndb.com/jokes/random"
resp = requests.get(url)
resp.encoding = "utf-8"
data = resp.json()
return (data["value"]["joke"])
def stormconsultancy_quotes():
url = "http://quotes.stormconsultancy.co.uk/random.json"
resp = requests.get(url)
resp.encoding = "utf-8"
data = resp.json()
return (data["quote"])
def cat_fact_quotes():
url = "https://cat-fact.herokuapp.com/facts/random"
resp = requests.get(url)
resp.encoding = "utf-8"
data = resp.json()
return (data["text"])
def get_msg():
x = random.randint(0,3)
if(x == 0):
return (geeks())
elif(x == 1):
return (chuck_norris())
elif(x == 2):
return (stormconsultancy_quotes())
elif(x == 3):
return (cat_fact_quotes())