Skip to content

Instantly share code, notes, and snippets.

@ruthtillman
Last active June 28, 2019 15:00
Show Gist options
  • Save ruthtillman/43842ae5d001781c59f950558eaec3ec to your computer and use it in GitHub Desktop.
Save ruthtillman/43842ae5d001781c59f950558eaec3ec to your computer and use it in GitHub Desktop.
curling LCCNs to madsrdf

curl http://id.loc.gov/authorities/names/nb2015017302.madsrdf.rdf -o nb2015017302.rdf

The difference here is you have to know what kind of authority you're querying. So you'll need to do names, subjects, etc. separately, whereas for the lccn query, it's straight-up lccn.

Working from a simple list:

names: for lccn in nb2015017302 n89223874; do curl http://id.loc.gov/authorities/names/$lccn.madsrdf.rdf -o $lccn.rdf; sleep 3; done

subjects: for lccn in sh2016002835 sh86003754; do curl http://id.loc.gov/authorities/subjects/$lccn.madsrdf.rdf -o $lccn.rdf; sleep 3; done

Separate lccns with a single space. BE SURE TO CHECK WHETHER YOU'RE DOING NAME, SUBJECT, ETC.

  • name = /names/
  • subject = /subjects/
  • other things will have their own too...

If it gets longer, consider making a full bash script, as below:

#!/bin/bash
for lccn in nb2015017302 n89223874 n82203435 n2017074015
do
  curl http://id.loc.gov/authorities/names/$lccn.madsrdf.rdf -o $lccn.rdf
  sleep 3
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment