您的问题是“如何开始使用 Flickr API for Python?”
我在 PyPi 中使用稍新的 2.4 版,也是由 Stuvel 开发的。你可以找到它here。在这个版本中,flickr 和 api 之间没有下划线。
我帐户中的所有照片都没有使用标签。相反,我将使用文本搜索。您应该了解以下内容的工作原理并尝试标签搜索。
另外,我返回的是解析的 json 而不是默认的 xml。这样做的好处是你得到了嵌套的字典,在 Python 中很容易解析和循环。
以下在 Spyder 中工作——Anaconda 中的交互式 shell。这个未签名的电话显示了我的公开照片。你应该得到相同的结果。
import flickrapi
FLICKR_PUBLIC = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX'
FLICKR_SECRET = 'XXXXXXXXXXXXXXX'
flickrapi.__version__
Out[4]: '2.4.0'
flickr = flickrapi.FlickrAPI(FLICKR_PUBLIC,FLICKR_SECRET,format='parsed-json')
MYSTUFF = "157919153@N05"
MyAtkinsons = flickr.photos.search(text="Atkinson",
user_id = MYSTUFF,
extras="description")
MyAtkinsons['photos']
Out[8]:
{'page': 1,
'pages': 1,
'perpage': 100,
'total': '7',
'photo': [{'id': '50109797342',
'owner': '157919153@N05',
'secret': 'a7d95d8c17',
'server': '65535',
'farm': 66,
'title': 'Atkinson, Everett W. and Olive E.',
'ispublic': 1,
'isfriend': 0,
'isfamily': 0,
'description': {'_content': 'Atkinson, Everett W. and Olive E.'}},
{'id': '50109558361',
'owner': '157919153@N05',
'secret': 'bd2eb4e88f',
'server': '65535',
'farm': 66,
'title': 'Atkinson, Jon Wesley',
'ispublic': 1,
'isfriend': 0,
'isfamily': 0,
'description': {'_content': 'Atkinson, Jon Wesley'}},
{'id': '46978210785',
'owner': '157919153@N05',
'secret': '299b85c928',
'server': '65535',
'farm': 66,
'title': '17azg7nf6jtz6',
'ispublic': 1,
'isfriend': 0,
'isfamily': 0,
'description': {'_content': 'Atkinson, Lawrence M.'}},
{'id': '47105017914',
'owner': '157919153@N05',
'secret': 'cfb49d8c5b',
'server': '65535',
'farm': 66,
'title': 'Atkinson, James L. and Florence',
'ispublic': 1,
'isfriend': 0,
'isfamily': 0,
'description': {'_content': 'Atkinson, James L. and Florence'}},
{'id': '47104538484',
'owner': '157919153@N05',
'secret': '7d52705223',
'server': '65535',
'farm': 66,
'title': '17bcqb9d4n66q',
'ispublic': 1,
'isfriend': 0,
'isfamily': 0,
'description': {'_content': 'Robbins, Vera M. Atkinson'}},
{'id': '47893343811',
'owner': '157919153@N05',
'secret': 'eed21d5a5c',
'server': '65535',
'farm': 66,
'title': '17be28jy5r95u',
'ispublic': 1,
'isfriend': 0,
'isfamily': 0,
'description': {'_content': 'Atkinson, Catherine M. and Lew H.'}},
{'id': '47086890614',
'owner': '157919153@N05',
'secret': '1e16987f8b',
'server': '65535',
'farm': 66,
'title': '17bds2q7ui24y',
'ispublic': 1,
'isfriend': 0,
'isfamily': 0,
'description': {'_content': 'Atkinson, James'}}]}
我的帐户中有七张阿特金森的照片,截至今日,这些照片可供公众使用。
如果您需要标签,请将其添加到 extras 参数中。我只是使用从 'id' 解析的照片的默认分辨率,所以我不会在 extras 参数中请求 URL。