/[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

Diff of /get_book.sh

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by dpavlin, Sat Jan 17 16:25:38 2004 UTC revision 1.8 by dpavlin, Tue Feb 17 19:06:10 2004 UTC
# Line 1  Line 1 
1  #!/bin/sh  #!/bin/sh
2    
3  # proxy settings (same as in firebird)  # proxy settings (same as in firebird)
4  ( ping proxy 2>&1 ) >/dev/null && export http_proxy=http://proxy:8080  fping proxy && export http_proxy=http://proxy:8080
5  # user agent (same as in firebird)  # user agent (same as in firebird)
6  ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031225 Firebird/0.7"  ua="Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.5) Gecko/20031225 Firebird/0.7"
7    
# Line 23  if [ -e orig ] ; then Line 23  if [ -e orig ] ; then
23          mv orig/* .          mv orig/* .
24          rm -Rf orig          rm -Rf orig
25    
26          grep -l 'promo.asp' * | xargs -i rm -v {}          grep -l 'promo.asp' * | xargs -i rm {}
27            grep -l 'This is only a preview of the full book' * | xargs -i rm {}
28  fi  fi
29    
30  isbn=$1;  isbn=$1;
# Line 37  function mirror() { Line 38  function mirror() {
38          file=`echo $url | sed -e s,http://[^?]*?,index.html?, -e s,#.*$,, -e s,/,%2F,g`          file=`echo $url | sed -e s,http://[^?]*?,index.html?, -e s,#.*$,, -e s,/,%2F,g`
39          if [ -e "$file" ] ; then          if [ -e "$file" ] ; then
40  #               echo "skip $url"  #               echo "skip $url"
41                    echo -n "."
42                  return                  return
43          fi          fi
44    
# Line 67  function geturl() { Line 69  function geturl() {
69          sed -e 's/^.*<a.*href="//i' \          sed -e 's/^.*<a.*href="//i' \
70                  -e 's/".*//' -e 's/amp;//g' \                  -e 's/".*//' -e 's/amp;//g' \
71                  -e 's,^[^\?]*\?,http://safari.oreilly.com/,' \                  -e 's,^[^\?]*\?,http://safari.oreilly.com/,' \
72                  -e 's/#$//' \                  -e 's/#.*$//' \
73                  -e 's/\&srchText=//' \                  -e 's/\&srchText=//' \
74                  -e 's/open=false/open=true/' | \                  -e 's/open=false/open=true/' | \
75                  grep '&s=1&b=1&f=1&t=1&c=1&u=1&r=&o=1' | \                  grep '&s=1&b=1&f=1&t=1&c=1&u=1&r=&o=1' | \
# Line 80  function uniqurl() { Line 82  function uniqurl() {
82          mv in in.tmp          mv in in.tmp
83          grep -v 'view=[A-Z]' in.tmp | sort -u > in          grep -v 'view=[A-Z]' in.tmp | sort -u > in
84          grep 'view=[A-Z].*/index' in.tmp | sort -u >> in          grep 'view=[A-Z].*/index' in.tmp | sort -u >> in
85            links=`wc -l in | cut -d" " -f1`
86            echo "found $links unique links"
87  }  }
88    
89  function mirror_in() {  function mirror_in() {
# Line 101  function mirror_in() { Line 105  function mirror_in() {
105                          echo "WARNING: your safari session is disabled. Aborting."                          echo "WARNING: your safari session is disabled. Aborting."
106                          exit 1                          exit 1
107                  fi                  fi
108    
109                    if grep -i 'This is only a preview of the full book' `ls -t index.html* | head -3` >/dev/null ; then
110                            echo "WARNING: you didn't add this book to your bookshelf!"
111                            exit 1
112                    fi
113          done          done
114            echo
115  }  }
116    
117  echo -n > in  echo -n > in
118  mirror "http://safari.oreilly.com/?XmlId=$isbn"  mirror "http://safari.oreilly.com/?XmlId=$isbn"
119    echo
120    
121  echo "extract URLs from first page..."  echo "extract URLs from first page..."
122  geturl "index.html?XmlId=$isbn" $isbn  geturl "index.html?XmlId=$isbn" $isbn

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.8

  ViewVC Help
Powered by ViewVC 1.1.26