Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- if [ -z "$1" ]; then
- echo "Please give me the initial URI so I know where to start from."
- exit 1
- fi
- init=$1
- album=$(echo $init | cut -d/ -f6 | cut -d- -f1)
- start=$(echo $init | cut -d/ -f6 | cut -d- -f2)
- baseurl=$(echo $init | cut -d/ -f3)
- mkdir -p $album/pages
- wget -nc -P $album/pages $init
- sed -i "s/>/>\n/g" $album/pages/$album-$start
- total=$(grep -B1 -m1 -P "http://.*org/img/l.png" $album/pages/$album-$start| grep -oP "(?<=href=\").*(?=\")" | cut -d/ -f6 | cut -d- -f2)
- nextpage=$(grep -m1 -oP "http://$baseurl/.*$album-$((start + 1))" $album/pages/$album-$start)
- wget -nc -P $album $(grep -oP "http://([0-9]{1,3}\.){3}[0-9]{1,3}.*\.(jpg|png|gif)" $album/pages/$album-$start | sed "s/\&/\&/g")
- for i in $(seq $start $total)
- do
- wget -nc -P $album/pages $nextpage
- until [ $(grep 'You are opening pages too fast, thus placing a heavy load on the server.' $album/pages/$album-$i | wc -l) -eq 0 ]
- # until [ $blocked -eq 0 ]
- do
- echo "Received warning from server. Sleeping for 30 seconds."
- sleep 30
- needrefresh=1
- done
- if [ ! -z $needrefresh ]; then
- rm -vf $album/pages/$album-$i
- wget -P $album/pages $nextpage
- unset needrefresh
- fi
- sed -i "s/>/>\n/g" $album/pages/$album-$i
- nextpage=$(grep -m1 -oP "http://$baseurl/.*$album-$((i + 1))" $album/pages/$album-$i)
- wget -nc -P $album $(grep -oP "http://([0-9]{1,3}\.){3}[0-9]{1,3}.*\.(jpg|png|gif)" $album/pages/$album-$i | sed "s/\&/\&/g")
- sleep 2
- # echo image = $(grep -oP "http://([0-9]{1,3}\.){3}[0-9]{1,3}.*\.jpg" $album/pages/$album-$i)
- done
- du -h $album
- echo $(find $album -maxdepth 1 -name "*.jpg" | wc -l) images exist
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement