-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathl8.py
More file actions
105 lines (95 loc) · 2.67 KB
/
l8.py
File metadata and controls
105 lines (95 loc) · 2.67 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
from credentials import creds
import requests
url = "https://spoonacular-recipe-food-nutrition-v1.p.rapidapi.com/recipes/complexSearch"
headers = {
"X-RapidAPI-Key": creds['X-RapidAPI-Key'],
"X-RapidAPI-Host": "spoonacular-recipe-food-nutrition-v1.p.rapidapi.com"
}
querystring = {
"query": "pasta",
"cuisine": "italian",
"excludeCuisine": "greek",
"diet": "vegetarian"
}
response = requests.request("GET", url, headers=headers, params=querystring)
print(response.text)
'''
{"results":
[
{
"id":104974,
"title":"Pasta Primavera",
"image":"https://spoonacular.com/recipeImages/104974-312x231.jpg",
"imageType":"jpg"
},
{
"id":246727,
"title":"Pasta e Fagioli",
"image":"https://spoonacular.com/recipeImages/246727-312x231.jpg",
"imageType":"jpg"
},
{
"id":118762,
"title":"Pasta Puttanesca",
"image":"https://spoonacular.com/recipeImages/118762-312x231.jpg",
"imageType":"jpg"
},
{
"id":154062,
"title":"Pasta à la Checca",
"image":"https://spoonacular.com/recipeImages/154062-312x231.jpg",
"imageType":"jpg"
},
{
"id":138832,
"title":"Pasta Cacio e Pepe",
"image":"https://spoonacular.com/recipeImages/138832-312x231.jpg",
"imageType":"jpg"
},
{
"id":26885,
"title":"Pasta Pomodoro My Way",
"image":"https://spoonacular.com/recipeImages/26885-312x231.jpg",
"imageType":"jpg"
},
{
"id":856159,
"title":
"Pasta Primavera Stuffed In Bell Pepper",
"image":"https://spoonacular.com/recipeImages/856159-312x231.jpg",
"imageType":"jpg"
},
{
"id":109882,
"title":"Pasta Primavera With Cherry Tomato Sauce",
"image":"https://spoonacular.com/recipeImages/109882-312x231.jpg",
"imageType":"jpg"
}
,
{
"id":516565,
"title":"Pasta alla Formiana (or a healthified baked “ziti”)",
"image":"https://spoonacular.com/recipeImages/516565-312x231.jpg",
"imageType":"jpg"
},
{
"id":486551,
"title":"Pasta alla puttanesca {literally whore’s style pasta}",
"image":"https://spoonacular.com/recipeImages/486551-312x231.jpg",
"imageType":"jpg"
}
],
"offset":0,
"number":10,
"totalResults":135
}
'''
url2 = 'https://random-d.uk/api/v2/random'
response2 = requests.request("GET", url2)
print(response2.json())
'''
{
'message': 'Powered by random-d.uk',
'url': 'https://random-d.uk/api/243.jpg'
}
'''