搜索未斜杠的照片
unsplash-search的Python项目详细描述
反斜杠搜索
unsplash search是一个小的python库,用于从unsplash照片宿主网站搜索照片。
安装
pip install unsplash-search
用法
导入UnsplashSearch模块
from unsplash_search import UnsplashSearch
必须从unsplash deverloper api网站获取访问密钥。
然后必须用密钥实例化unsplashsearch类才能使用该程序。
unsplash = UnsplashSearch(YOUR_KEY)
使用查询进行搜索
unsplash搜索方法接受一个查询作为参数,以确定您的照片类型 想要得到。
如果成功,它将返回一个随机图像字典。
img = unsplash.search('mountains') #=> dict
image dictionary对象有两个键:图像的url和作者的instagram用户名。
因此,如果您只想获得与查询匹配的随机图像,请执行以下操作
img['img']