-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageSearchAPITest.py
43 lines (31 loc) · 1.02 KB
/
ImageSearchAPITest.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
42
43
import requests
URL = "https://rapidapi.p.rapidapi.com/api/Search/ImageSearchAPI"
HEADERS = {
'x-rapidapi-host': "contextualwebsearch-websearch-v1.p.rapidapi.com",
'x-rapidapi-key': "Your-X-RapidAPI-Key"
}
q = "taylor swift"
page_number = 1
page_size = 10
auto_correct = True
safe_search = False
querystring = {"q": q,
"pageNumber": page_number,
"pageSize": page_size,
"autoCorrect": auto_correct,
"safeSearch": safe_search}
response = requests.get(URL, headers=HEADERS, params=querystring).json()
print(response)
totalCount = response["totalCount"]
for image in response["value"]:
url = image["url"]
name = image["name"]
title = image["title"]
provider = image["provider"]["name"]
image_url = image["url"]
image_height = image["height"]
imageWidth = image["width"]
thumbnail = image["thumbnail"]
thumbnail_height = image["thumbnailHeight"]
thumbnail_width = image["thumbnailWidth"]
print("Url: %s. Title: %s." % (url, name))