0

我在 GitHub 上找到了这个功能

def searchFlickrImages(term, category='architecture'):
# takes a term and returns a drawing of it
flickr = flickrapi.FlickrAPI(api_key, api_secret, format='xmlnode')
print('searching for term: ' + term + ' in category: ' + category)
returnedImages = flickr.photos_search(text=term, tags=category, per_page=5, pages=1, extras='url_o', sort='interestingness-desc')
try:
    g = returnedImages.photos[0].photo[0]
    fl_farm = returnedImages.photos[0].photo[0].attrib['farm']
    fl_server = returnedImages.photos[0].photo[0].attrib['server']
    fl_id = returnedImages.photos[0].photo[0].attrib['id']
    fl_secret = returnedImages.photos[0].photo[0].attrib['secret']
    fl_url = 'http://farm' + fl_farm + '.static.flickr.com/' + fl_server + '/' + fl_id + '_' + fl_secret + '_m.jpg'
    print(fl_url)
    return(fl_url)
except:
    print('no photo received')
    return ''

它从 flickr 打印属于某个类别的图像(例如:架构)并使用关键字术语(例如:狗)问题是我想同时使用多个术语执行图像搜索(例如:狗,猫,bird) 例如,在同一个图像中,flickr.photos_search 是否可能在同一个请求中采用多个术语或类别,或者是否有任何其他想法可以完成这项工作。

谢谢

4

0 回答 0