Created
May 11, 2015 16:26
-
-
Save DominicBM/4871b32c61535737cc06 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
import requests, json, csv | |
r = json.loads(requests.get('https://catalog.archives.gov/api/v1?naIds=10534724').text) | |
for key0 in r['opaResponse']['results']['result'][0].keys(): | |
print key0 | |
try: | |
for key1 in r['opaResponse']['results']['result'][0][key0].keys(): | |
print key0 + '.' + key1 | |
try: | |
for key2 in r['opaResponse']['results']['result'][0][key0][key1].keys(): | |
print key0 + '.' + key1 + '.' + key2 | |
try: | |
for key3 in r['opaResponse']['results']['result'][0][key0][key1][key2].keys(): | |
print key0 + '.' + key1 + '.' + key2 + '.' + key3 | |
try: | |
for key4 in r['opaResponse']['results']['result'][0][key0][key1][key2][key3].keys(): | |
print key0 + '.' + key1 + '.' + key2 + '.' + key3 + '.' + key4 | |
try: | |
for key5 in r['opaResponse']['results']['result'][0][key0][key1][key2][key3][key4].keys(): | |
print key0 + '.' + key1 + '.' + key2 + '.' + key3 + '.' + key4 + '.' + key5 | |
try: | |
for key6 in r['opaResponse']['results']['result'][0][key0][key1][key2][key3][key4][key5].keys(): | |
print key0 + '.' + key1 + '.' + key2 + '.' + key3 + '.' + key4 + '.' + key5 + '.' + key6 | |
except AttributeError: | |
continue | |
except AttributeError: | |
continue | |
except AttributeError: | |
continue | |
except AttributeError: | |
continue | |
except AttributeError: | |
continue | |
except AttributeError: | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment