Skip to content

Instantly share code, notes, and snippets.

@DominicBM
Created May 11, 2015 16:26
Show Gist options
  • Save DominicBM/4871b32c61535737cc06 to your computer and use it in GitHub Desktop.
Save DominicBM/4871b32c61535737cc06 to your computer and use it in GitHub Desktop.
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