Created
May 27, 2018 11:21
-
-
Save prakhar21/19182a22dee00d108b4ac636a95f1d86 to your computer and use it in GitHub Desktop.
Get Collection ids.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import requests | |
import config | |
import get_cityids | |
def run(): | |
collection_id = {} | |
'''calling city id''' | |
city_id_mappings = get_cityids.run() | |
for city, id_ in city_id_mappings.items(): | |
parameters = {'city_id': id_} | |
header = {"user-key":config.APP_KEY} | |
response = requests.get( | |
config.COLLECTIONS_API, | |
params=parameters, | |
headers=header | |
) | |
collection = response.json().get('collections') | |
temp = [] | |
for cid in collection: | |
temp.append(cid.get('collection').get('collection_id')) | |
collection_id[city] = {'id': id_, 'collection': temp} | |
return collection_id | |
if __name__ == '__main__': | |
collection_ids = run() | |
print collection_ids |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment