Free_Image2 / app.py
ckfrpark's picture
Rename apy.py to app.py
36a2859 verified
raw
history blame
721 Bytes
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)