summaryrefslogtreecommitdiff
path: root/scrape-bnf.sh
diff options
context:
space:
mode:
authorNick White <git@njw.name>2019-02-25 17:19:48 +0000
committerNick White <git@njw.name>2019-02-25 17:19:48 +0000
commit0aec35a060a9f9e1e33c18bf0e2af2aafd6a6257 (patch)
tree06681e52bf515814728e87c3971b50b178d9b480 /scrape-bnf.sh
Add various helper scripts
Diffstat (limited to 'scrape-bnf.sh')
-rw-r--r--scrape-bnf.sh17
1 files changed, 17 insertions, 0 deletions
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