在python中使用pexels api v1
pexels-api的Python项目详细描述
在python中使用pexels api v1
使用pexels_api从Pexels搜索照片。
依赖关系:
安装:
pip install pexels-api
用法:
下面的代码向您展示了如何导入包并对pexels api v1进行简单的查询。查看更多examples或documentation。
# Import API class from pexels_api packagefrompexels_apiimportAPI# Type your Pexels APIPEXELS_API_KEY='YOUR-PEXELS-API-KEY'# Create API objectapi=API(PEXELS_API_KEY)# Search five 'kitten' photosapi.search('kitten',page=1,results_per_page=5)# Get photo entriesphotos=api.get_entries()# Loop the five photosforphotoinphotos:# Print photographerprint('Photographer: ',photo.photographer)# Print urlprint('Photo url: ',photo.url)# Print original size urlprint('Photo original size: ',photo.original)