Created
May 27, 2018 11:19
-
-
Save prakhar21/e968f22b4da3d2d0c60406b3bad8858d to your computer and use it in GitHub Desktop.
Get city 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 | |
def run(): | |
city_id_mapping = {} | |
for city in config.CITIES: | |
parameters = {'q': city} | |
header = {"user-key":config.APP_KEY} | |
response = requests.get( | |
config.CITY_ID_API, | |
params=parameters, | |
headers=header | |
) | |
city_id_mapping[city] = response.json().get('location_suggestions')[0]["id"] | |
return city_id_mapping | |
if __name__ == '__main__': | |
mappings = run() | |
print mappings |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment