Advertisement
metalx1000

Get Mugshots

Feb 5th, 2015
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.90 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. if [ $# -lt 1 ]
  4. then
  5.   echo """
  6.    Usage: $0 <name>
  7.    Example: $0 John Smith
  8.  """
  9.   exit 0
  10. fi
  11.  
  12. name=$@
  13. name_dir="$(echo "$name"|sed 's/ /_/g')"
  14. dir="${name_dir}_mugshots"
  15. url="http://mugshots.com/search.html?q=$name"
  16. url2="$url&page="
  17. agent="Mozilla/5.0 (Windows NT 5.2; rv:2.0.1) Gecko/20100101 Firefox/4.0.1"
  18.  
  19. #Get total number of page results
  20. let entries=$(wget "$url" --user-agent="$agent" -q -O-|\
  21.   grep details|\
  22.   grep result|\
  23.   cut -d\( -f2|awk '{print $1}')
  24.  
  25. echo "Found $entries results."
  26.  
  27. if [ $entries -lt 1 ]
  28. then
  29.   echo "No entries found!"
  30.   exit
  31. fi
  32.  
  33. let pages=$entries/10
  34.  
  35. if [ $pages -lt 1 ]
  36. then
  37.   pages=1
  38. fi
  39.  
  40. mkdir "$dir"
  41. cd "$dir"
  42.  
  43. for i in `seq 1 $pages`
  44. do
  45.   wget "$url2" --user-agent="$agent" -q -O-|\
  46.   grep thumbs|\
  47.   grep jpg|\
  48.   cut -d\" -f2|\
  49.   sed 's/223x223/400x800/g'|\
  50.   while read img
  51.   do
  52.     wget "$img"
  53.   done
  54. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement