|
import requests |
|
|
|
def fetch_high_quality_images(api_key, query, per_page=80): |
|
url = "https://api.pexels.com/v1/search" |
|
headers = { |
|
"Authorization": api_key |
|
} |
|
params = { |
|
"query": query, |
|
"per_page": per_page, |
|
"size": "large" |
|
} |
|
response = requests.get(url, headers=headers, params=params) |
|
if response.status_code == 200: |
|
images = response.json()['photos'] |
|
for image in images: |
|
print(image['src']['original']) |
|
else: |
|
print("Error:", response.status_code) |
|
|
|
if __name__ == "__main__": |
|
api_key = "5woz23MGx1QrSY0WHFb0BRi29JvbXPu97Hg0xnklYgHUI8G0w23FKH62" |
|
query = input("검색할 이미지의 키워드를 입력하세요: ") |
|
fetch_high_quality_images(api_key, query) |