Skip to content

Instantly share code, notes, and snippets.

View DominicBM's full-sized avatar

Dominic Byrd-McDevitt DominicBM

View GitHub Profile
import requests, json, os, csv, argparse
parser = argparse.ArgumentParser()
parser.add_argument('--file', dest='file', metavar='FILE',
action='store')
args = parser.parse_args()
file = args.file
newfile = 'NAIDs - ' + args.file
{
"opaResponse":{
"header":{
"@status":"200",
"time":"2015-03-12T23:33:56.039Z",
"request":{
"@action":"save",
"@path":"\/api\/v1\/id\/7000802\/tags",
"format":"json",
"pretty":true,
import ttk, json, requests, PIL, os
from Tkinter import *
from ttk import Frame, Style
from PIL import Image, ImageTk
def topic(*args):
topics = topictext.get()
image = json.loads(requests.get('https://uat.research.archives.gov/api/v1/?resultTypes=object&rows=200&description.item.scopeAndContentNote=' + topics).text)
total = image['opaResponse']['results']['total'] - 1
if total > 199 :
import requests, json, argparse, random, os, Tkinter
parser = argparse.ArgumentParser()
parser.add_argument('--naid', dest='naid', metavar='NAID',
action='store')
parser.add_argument('--tag', dest='tag', metavar='TAG',
action='store')
parser.add_argument('--user', dest='user', metavar='USER',
action='store')
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:
import requests, json, csv, re, string, argparse
logfile = 'fields.csv'
offset = 0
while offset < 6000 :
r = requests.get('https://catalog.archives.gov/api/v1?type=topical-subject&rows=200&offset=' + str(offset)).text
r = re.sub('( *)(\"@user.*?)\"\$\"',r'\1\2\n\1"$"', r)
m = string.split(r, '\n')
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
"num"
"type"
"naId"
"authority"
"authority.topicalSubject"
"authority.topicalSubject.naId"
"authority.topicalSubject.termName"
"authority.topicalSubject.isPreferred"
"authority.topicalSubject.isUnderEdit"
"authority.topicalSubject.isReference"
18503259 07542
18475522 28003
18471472 05386
17412775 14289
17408517 27799
17408508 27773
17408507 27772
17408488 27714
17408487 27714
17408401 27426
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests, json, csv, argparse
parser = argparse.ArgumentParser()
parser.add_argument('--series_NAID', dest='series_NAID', metavar='SERIES_NAID',
action='store')
parser.add_argument('--file_units', dest='file_units', metavar='FILE_UNITS',
action='store')
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
<head>
<title>Upcoming Events</title>
<meta http-equiv="Content-Type" content="text/html;" />
<meta http-equiv="Content-Language" content="en-US" />
<link rel="icon" href="http://archives.gov/favicon.ico" type="image/x-icon" />
<link rel="shortcut icon" href="http://archives.gov/favicon.ico" />