本文整理汇总了Python中flickrapi.FlickrAPI.walk方法的典型用法代码示例。如果您正苦于以下问题:Python FlickrAPI.walk方法的具体用法?Python FlickrAPI.walk怎么用?Python FlickrAPI.walk使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类flickrapi.FlickrAPI
的用法示例。
在下文中一共展示了FlickrAPI.walk方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sleep
# 需要导入模块: from flickrapi import FlickrAPI [as 别名]
# 或者: from flickrapi.FlickrAPI import walk [as 别名]
start=min_date,
end=max_date,
),
end=""
)
success = False
while not success:
sleep(2)
try:
# iterator over search results
walker = api.walk(
min_taken_date=min_date,
max_taken_date=max_date,
**search_args
)
# collect results
data = [convert_values(elem) + get_size(elem)
for elem in walker]
except KeyboardInterrupt as e:
raise KeyboardInterrupt(e)
except:
sys.stderr.write("failed, trying again...\n")
else:
success = True
csv_writer.writerows(data)
print("fetched {n} photos".format(n=len(data)))
示例2: FlickrAPI
# 需要导入模块: from flickrapi import FlickrAPI [as 别名]
# 或者: from flickrapi.FlickrAPI import walk [as 别名]
from flickrapi import FlickrAPI, shorturl
import urllib
API_KEY= '334cf7234def6ecea68c28886e7926f9'
SECRET = '3afd55d06e53ac92'
flickr = FlickrAPI(API_KEY, SECRET)
if __name__ == '__main__':
favs = flickr.walk(tags="skin lesion", per_page="1500")
dest_dir = 'images/'
for i, photo in enumerate(favs):
title= photo.get('title')
ident = photo.get('id')
local = '%s%s_.jpg'%(dest_dir,title)
farm = photo.get('farm')
server = photo.get('server')
secret = photo.get('secret')
try:
prefix = "http://farm" + farm + ".staticflickr.com/"+server+"/"
suffix = ident + "_"+secret+"_b.jpg"
url = prefix + suffix
urllib.urlretrieve(url, local)
except: