Skip to content

Instantly share code, notes, and snippets.

@netsensei
Last active November 10, 2018 17:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save netsensei/4eafb57402b8e68d32e68e2b02bdf925 to your computer and use it in GitHub Desktop.
Save netsensei/4eafb57402b8e68d32e68e2b02bdf925 to your computer and use it in GitHub Desktop.
Scrape the Metropolitan Museum API
#!/bin/bash
echo "fetching list of objects";
curl -s "https://collectionapi.metmuseum.org/public/collection/v1/objects" > list.json;
echo "[]" > objects.json;
echo "drawing list of objects";
ids=$(jq -r '.objectIDs | .[]' list.json);
rm list.json;
echo "fetching objects";
for id in ${ids[@]};
do
echo "fetching item #${id}";
res=$(curl -s "https://collectionapi.metmuseum.org/public/collection/v1/objects/${id}");
jq --argjson obj "${res}" '. + [$obj]' < objects.json > tmp.json;
mv tmp.json objects.json;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment