Spaces:
Runtime error
Runtime error
File size: 721 Bytes
6e755a1 |
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 |
import requests
# Pexels API 키 설정
API_KEY = 'XDDeRl6U3IY8VRzv7YBGRrnGuOwqpOYD2yS9VTAYM7VEfZcr1aWXubZ1'
API_ENDPOINT = 'https://api.pexels.com/v1/search'
def fetch_high_quality_images(keyword, per_page=80):
headers = {
'Authorization': API_KEY
}
params = {
'query': keyword,
'per_page': per_page,
'size': 'large'
}
response = requests.get(API_ENDPOINT, headers=headers, params=params)
if response.status_code == 200:
data = response.json()
images = data['photos']
for image in images:
print(image['src']['original'])
if __name__ == '__main__':
keyword = input("Enter keyword: ")
fetch_high_quality_images(keyword) |