Skip to content

Instantly share code, notes, and snippets.

@prakhar21
Created May 27, 2018 11:19
Show Gist options
  • Save prakhar21/e968f22b4da3d2d0c60406b3bad8858d to your computer and use it in GitHub Desktop.
Save prakhar21/e968f22b4da3d2d0c60406b3bad8858d to your computer and use it in GitHub Desktop.
Get city ids.
#!/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