Last active
November 10, 2018 17:44
-
-
Save netsensei/4eafb57402b8e68d32e68e2b02bdf925 to your computer and use it in GitHub Desktop.
Scrape the Metropolitan Museum API
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
#!/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