我flickrapi.exceptions.FlickrError: Error: 1: Photo not found
在下面的代码中得到一个异常,在这一行:
sizes_element = self.flickr.photos_getSizes(k_id = id)
但是,根据我的photo_id
说法,我通过的是正确的。
import flickrapi
class FlickrDownloader():
def __init__(self,key,secret):
self.api_key = key
self.secret = secret
self.flickr = flickrapi.FlickrAPI(self.api_key,self.secret)
def getUrls(self):
self.photos = self.flickr
self.urlList = []
#get a list of photos
photo_element = self.flickr.photos_search(tags = 'flowers',per_page = '10')
#get and iterator over elements
photo_iter = photo_element.iter('photo')
self.i = 0
for photo in photo_iter:
#get the photo id
id = photo.attrib['id']
print id
#get the different sizes of photo
sizes_element = self.flickr.photos_getSizes(k_id = id)
#get an interator
sizes_iter = sizes_element.iter('size')
#iterate over the sizes
for size in sizes_iter:
#check if its original size
if size.attrib['label'] == 'Original':
self.urlList.append(size.attrib['source'])
return self.urlList