Advertisement
Guest User

Untitled

a guest
Aug 29th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.62 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -ne 1 ]; then
  4.     echo "usage: $0 format"
  5.     echo "NB: page numbers start at 1"
  6.     echo "NB: format should have leading 0 information"
  7.     echo "example:"
  8.     echo "$0 http://example.net/path/chapter/%04d.jpg"
  9.     exit
  10. fi
  11.  
  12. format=$1
  13.  
  14. echo "Start $format"
  15.  
  16. getpage() {
  17.     url=$(printf $format $pagenum)
  18.     wget $url 2> /tmp/$$.log
  19.     if grep "404 Not Found" /tmp/$$.log; then return 1;
  20.     elif grep "Length: unspecified [text/html]" /tmp/$$.log; then return 1;
  21.     else return 0;
  22.     fi
  23. }
  24.  
  25. pagenum=1
  26. while getpage; do
  27.     echo "$pagenum complete."
  28.     pagenum=$(($pagenum + 1))
  29. done
  30.  
  31. echo "End $format"
  32.  
  33. rm -f /tmp/$$.log
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement