- #!/bin/bash
- THREAD_NUM=10
- url=$1
- for i in {2..2300}; do
- {
- curl "http://${url}.tumblr.com/page/"$i/ |grep -o "<img src.*\\"" |grep "[^(com)]/tumblr" |grep -o "http[^\\"]*" |xargs wget -P ${url} -t15 -T20 ||break;
- }&
- while [ $( jobs | wc -l ) -ge "$THREAD_NUM" ]; do
- sleep 0.5
- done
- done
- wait
- exit 0
- #该片段来自于http://www.codesnippet.cn/detail/2301201511623.html
来源: http://www.codesnippet.cn/detail/2301201511623.html