/[safari]/get_book.sh
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Annotation of /get_book.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.2 - (hide annotations)
Sun Dec 14 22:27:18 2003 UTC (20 years, 4 months ago) by dpavlin
Branch: MAIN
Changes since 1.1: +31 -13 lines
File MIME type: application/x-sh
lot of improvements. It should be working now, by creating directory
and invoking ../safari/get_book 0-000-00000-0

1 dpavlin 1.1 #!/bin/sh
2    
3 dpavlin 1.2 #export http_proxy=http://proxy:8080
4 dpavlin 1.1
5 dpavlin 1.2 if [ -z "$1" ] ; then
6     echo "Usage: $0 ISBN"
7     exit 1
8     fi
9    
10     isbn=$1;
11 dpavlin 1.1
12     wait=10
13    
14     isbn2=`echo $isbn | sed 's/-//g'`
15    
16     function mirror() {
17     wget -p -nH -nc -k \
18     --random-wait --wait=$wait -t 0 \
19     --load-cookies=/home/dpavlin/.phoenix/default/g6b45nt6.slt/cookies.txt \
20     -U "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031206 Firebird/0.7" \
21     $1
22    
23     # -D safari.oreilly.com \
24     # -A 0-201-41975-0 \
25     }
26    
27     function geturl() {
28 dpavlin 1.2 hindent -s $1 | grep -i href | grep mode=[st][eo]c | \
29 dpavlin 1.1 sed -e 's/^.*<a.*href="//i' \
30     -e 's/".*//' -e 's/amp;//g' \
31     -e 's,^[^\?]*\?,http://safari.oreilly.com/,' \
32     -e 's/#$//' \
33 dpavlin 1.2 -e 's/\&srchText=//' \
34     -e 's/open=false/open=true/' | \
35 dpavlin 1.1 grep '&s=1&b=1&f=1&t=1&c=1&u=1&r=&o=1' | \
36 dpavlin 1.2 grep $2 | \
37 dpavlin 1.1 sort -u >> in
38     }
39    
40 dpavlin 1.2 function uniqurl() {
41     mv in in.tmp
42     grep -v 'view=[A-Z]' in.tmp | sort -u > in
43     grep 'view=[A-Z].*/index' in.tmp | sort -u >> in
44     }
45    
46 dpavlin 1.1 echo > in
47 dpavlin 1.2 mirror "http://safari.oreilly.com/?XmlId=$isbn"
48 dpavlin 1.1
49     echo "extract URLs from first page..."
50     geturl "index.html?XmlId=$isbn" $isbn
51 dpavlin 1.2 uniqurl
52 dpavlin 1.1
53     mirror "-i in"
54    
55     echo -n "extracting URLs [1]"
56     ls index.html* | while read file ; do
57     echo -n "."
58     geturl $file $isbn
59     done
60     echo
61    
62 dpavlin 1.2 uniqurl
63 dpavlin 1.1
64 dpavlin 1.2 mirror "-i in"
65 dpavlin 1.1
66     echo > in
67     echo -n "extracting URLs [2]"
68     ls index.html* | while read file ; do
69     echo -n "."
70     geturl $file $isbn
71     done
72    
73 dpavlin 1.2 uniqurl
74    
75     mirror "-i in"
76    
77     # convert links in html
78     bn=`basename $0`
79     dir=`echo $0 | sed "s/$bn$//"`
80     ls index.html* | xargs -i $dir/filter.pl {}
81     mkdir orig
82     mv index.html* orig/
83 dpavlin 1.1

  ViewVC Help
Powered by ViewVC 1.1.26