From 0aec35a060a9f9e1e33c18bf0e2af2aafd6a6257 Mon Sep 17 00:00:00 2001 From: Nick White Date: Mon, 25 Feb 2019 17:19:48 +0000 Subject: Add various helper scripts --- scrape-bnf.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 scrape-bnf.sh (limited to 'scrape-bnf.sh') diff --git a/scrape-bnf.sh b/scrape-bnf.sh new file mode 100644 index 0000000..677e4d4 --- /dev/null +++ b/scrape-bnf.sh @@ -0,0 +1,17 @@ +#!/bin/sh +usage="Usage: $0 bnfurl" + +test $# -ne 1 && echo "$usage" && exit 1 + +bookid=`echo "$1" |awk -F / '{printf("%s/%s\n", $5, $6)}'` +bookid_name=`echo "$bookid" | sed 's/\//_/'` + +html=`curl -s "https://gallica.bnf.fr/ark:/${bookid}"` + +pagenum=`echo "$html" | sed 's/.*nbTotalVues\\\"://g' | sed 's/,.*//'` + +for i in `seq "$pagenum"`; do + pgname=`printf "%s_%03d" "${bookid_name}" "${i}"` + echo "Downloading page $i of $pagenum to ${pgname}.jpg" + curl -s "https://gallica.bnf.fr/iiif/ark:/${bookid}/f${i}/full/full/0/native.jpg" > "${pgname}.jpg" +done -- cgit v1.2.1-24-ge1ad