本文整理匯總了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: