2008-02-20 01:59:20 Amazon book image grabber script
( sh )
  1  #!/bin/sh
2
dir="/some/dir/of/bookImages"
3 tempFile="/tmp/bookimagetemp"
4
5 if [ "$#" -ne 1 ]
6 then
7 echo "Usage: miniBookGrab (isbn)"
8 exit 1
9 else
10 if [ -f "$dir/$1.2.jpg" ]
11 then
12 echo "Image for ISBN $1 already exists."
13 exit 0
14 else
15 curl -s "http://www.amazon.com/dp/$1/" -A "Mozilla/5.0" > $tempFile
16 rm $tempFile
17 curl -s "http://ec1.images-amazon.com/images/P/$1.01._SCTHUMBZZZ_.jpg" -o $dir/$1.jpg
18 if [ -f "$dir/$1.jpg" ]
19 then
20 echo "Image imported."
21 exit 0
22 else
23 echo "Import failed."
24 exit 1
25 fi
26
fi
27
fi
28
Leave a comment