1 |
#!/bin/sh |
#!/bin/sh |
2 |
|
|
3 |
#export http_proxy=http://proxy:8080 |
export http_proxy=http://proxy:8080 |
4 |
|
|
5 |
if [ -z "$1" ] ; then |
if [ -z "$1" ] ; then |
6 |
echo "Usage: $0 ISBN" |
echo "Usage: $0 ISBN" |
43 |
grep 'view=[A-Z].*/index' in.tmp | sort -u >> in |
grep 'view=[A-Z].*/index' in.tmp | sort -u >> in |
44 |
} |
} |
45 |
|
|
46 |
function checklogin() { |
function mirror_in() { |
47 |
if grep 'promo.asp' index.html* >/dev/null ; then |
cat in | while read url ; do |
48 |
echo "WARNING: safari seems to logunt you as user. Aborting." |
mirror "$url" |
49 |
exit 1 |
|
50 |
fi |
if grep 'promo.asp' `ls -t index.html* | head -3` >/dev/null ; then |
51 |
|
echo "WARNING: safari seems to logunt you as user. Aborting." |
52 |
|
exit 1 |
53 |
|
fi |
54 |
|
done |
55 |
} |
} |
56 |
|
|
57 |
echo > in |
echo -n > in |
58 |
mirror "http://safari.oreilly.com/?XmlId=$isbn" |
mirror "http://safari.oreilly.com/?XmlId=$isbn" |
59 |
|
|
60 |
echo "extract URLs from first page..." |
echo "extract URLs from first page..." |
61 |
geturl "index.html?XmlId=$isbn" $isbn |
geturl "index.html?XmlId=$isbn" $isbn |
62 |
uniqurl |
uniqurl |
63 |
|
|
64 |
mirror "-i in" |
mirror_in |
|
checklogin |
|
65 |
|
|
66 |
echo -n "extracting URLs [1]" |
echo -n "extracting URLs [1]" |
67 |
ls index.html* | while read file ; do |
ls index.html* | while read file ; do |
72 |
|
|
73 |
uniqurl |
uniqurl |
74 |
|
|
75 |
mirror "-i in" |
mirror_in |
|
checklogin |
|
76 |
|
|
77 |
echo > in |
echo -n > in |
78 |
echo -n "extracting URLs [2]" |
echo -n "extracting URLs [2]" |
79 |
ls index.html* | while read file ; do |
ls index.html* | while read file ; do |
80 |
echo -n "." |
echo -n "." |
83 |
|
|
84 |
uniqurl |
uniqurl |
85 |
|
|
86 |
mirror "-i in" |
mirror_in |
|
checklogin |
|
87 |
|
|
88 |
# convert links in html |
# convert links in html |
89 |
bn=`basename $0` |
bn=`basename $0` |