-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmy_apis.py
28 lines (22 loc) · 872 Bytes
/
my_apis.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
import requests
import json
import html
dad_joke_url = "https://dad-jokes.p.rapidapi.com/random/joke"
yo_momma_joke_url = "https://api.yomomma.info/"
evil_insult_url = "https://evilinsult.com/generate_insult.php"
dad_joke_headers = {
'x-rapidapi-key': "a8703ff064msh7a09c106cbbb443p1425f2jsn3dddefa8add1",
'x-rapidapi-host': "dad-jokes.p.rapidapi.com"
}
def get_dad_joke():
response = requests.request("GET", dad_joke_url, headers=dad_joke_headers)
joke_body = json.loads(response.text)['body'][0]
return html.unescape(joke_body)
def get_yo_momma_joke():
response = requests.request("GET", yo_momma_joke_url)
joke_body = json.loads(response.text)['joke']
return html.unescape(joke_body)
def get_evil_insult():
response = requests.request("GET", evil_insult_url)
insult = html.unescape(response.text)
return insult