I'm writing a script in Python, using the flickr.photos.search API to retrieve a JSON object containing ids and infos of photos with a specific tag.
response = flickr.photos.search(api_key = api_key, tags='painting')
This is what "response" looks like:
{'photos': {'page': 1, 'pages': 7112, 'perpage': 100, 'total': '711114', 'photo': [
{'id': '33675403798', 'owner': '93779577@N00', 'secret': 'cb33cbcde6', 'server': '7914', 'farm': 8, 'title': ' Door 5302AA', 'ispublic': 1, 'isfriend': 0, 'isfamily': 0},
{'id': '40586047293', 'owner': '93779577@N00', 'secret': 'd4a0df639e', 'server': '7849', 'farm': 8, 'title': 'Elevator Door 5302', 'ispublic': 1, 'isfriend': 0, 'isfamily': 0},
{'id': '33675168088', 'owner': '164939965@N03', 'secret': '8d271064e7', 'server': '7857', 'farm': 8, 'title': 'A New Shade Of Blue', 'ispublic': 1, 'isfriend': 0, 'isfamily': 0},
{'id': '32582314737', 'owner': '81035653@N00', 'secret': 'e78b4f7235', 'server': '7821', 'farm': 8, 'title': 'Saint Michael', 'ispublic': 1, 'isfriend': 0, 'isfamily': 0},
]},
'stat': 'ok'}
From this I would like to create Python list that contains only the "id"s of the photos, something that would look like this:
['33675403798', '40586047293', '33675168088', '32582314737']
How can I extract only the ids and create a list?
EDIT:
Thank you to anyone who took the time to help me!
I managed to create the list using this code:
tag="painting"
response = flickr.photos.search(api_key = api_key, tags=tag)
photo_list=[]
for record in response['photos']['photo']:
s=record["id"]
photo_list.append(s)
I hope it can help someone in the future.