Last active
August 10, 2016 00:25
-
-
Save chriswebb09/7d31c3daa0ee3908cde76158601826dd to your computer and use it in GitHub Desktop.
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 Python3.5 | |
# -*- Coding: UTF-8 -*- | |
import requests | |
import json | |
def send_get_request(url, headers, payload): | |
r = requests.get(url, headers=headers, data=payload) | |
return r.json() | |
def send_post_request(url, headers, payload): | |
r = requests.post(url, headers=headers, json=payload) | |
return r.json() | |
if __name__ == '__main__': | |
city_url = "http://citysdk.commerce.gov" | |
city_headers = { "Authorization": "Basic MzE2M2I5NzFlZDVkZjg4NTQ5YTY1NzYzOTAxYTg5NDVhNzA1YWEwNTo="} | |
city_payload = {"level" : "tract", "sublevel":"true", | |
"zip" : "10001", "variables" : ["age", "income"], "api":"acs5","year":"2014"} | |
city_data = send_post_request(city_url, city_headers, city_payload) | |
census_url = "http://api.census.gov/data/2014/acs5?get=B19013_001E,B01002_001E&for=zip+code+tabulation+area:10004" | |
census_headers = {} | |
census_payload = {} | |
for i in city_data["features"]: | |
print(i["type"]) | |
print(i["bbox"]) | |
print(i["id"]) | |
print(i["geometry"]["bbox"]) | |
for n in i["geometry"]["coordinates"][0]: | |
print(n) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment