--- get_book.sh 2004/02/17 19:06:10 1.8 +++ get_book.sh 2004/06/02 16:14:53 1.9 @@ -3,7 +3,8 @@ # proxy settings (same as in firebird) fping proxy && export http_proxy=http://proxy:8080 # user agent (same as in firebird) -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.6) Gecko/20040506 Firefox/0.8" +cookie_file="cookie.txt" # wait between pages export wait=120 @@ -27,9 +28,7 @@ grep -l 'This is only a preview of the full book' * | xargs -i rm {} fi -isbn=$1; - -isbn2=`echo $isbn | sed 's/-//g'` +isbn=`echo $1 | sed 's/-//g'` function mirror() { @@ -42,24 +41,32 @@ return fi + cookie="" if echo $url | grep '/index' >/dev/null ; then - cookies="" echo -n "no login (index) " elif echo $url | grep 'mode=toc' >/dev/null ; then - cookies="" echo -n "no login (toc) " else - cookies="--load-cookies=/home/dpavlin/.phoenix/default/g6b45nt6.slt/cookies.txt" - echo -n "with login " + if [ ! -e $cookie_file ] ; then + echo "cookies file $cookie_file doesn't exits! Please create it." + echo "It should be in format:" + echo "Cookie: Site=UICode=&Portal=oreilly&GUID=..." + exit 1 + fi + read cookie < $cookie_file + if [ -z "$cookie" ] ; then + echo "Empty cookie file $cookie_file !" + exit 1 + fi fi - echo $url - wget -p -nH -nc -k \ - -t 1 -U "$ua" \ - $cookies $url + if [ -z "$cookie" ] ; then + echo "$url [no cookie]" + else + echo "$url [with cookie]" + fi -# -D safari.oreilly.com \ -# -A 0-201-41975-0 \ + wget -q -p -nH -nc -k -t 1 -U "$ua" --cookies=off --header="$cookie" $url perl -e '$t=rand($ENV{wait} || 30);print "sleep for $t sec.\n"; sleep($t);' }