#/bin/bash
# 设置并发的进程数
thread_num=5
a=$(date +%H%M%S)
# mkfifo
tempfifo="my_temp_fifo"
mkfifo ${tempfifo}
# 使文件描述符为非阻塞式
exec 6<>${tempfifo}
rm -f ${tempfifo}
# 为文件描述符创建占位信息
for ((i=1;i<=${thread_num};i++))
do
{
echo
}
done >&6
echo "==========================="
for i in `cat type`;do
echo $i 0 >> data
done
for i in `seq 0 15 165`;do
echo $i
curl https://movie.douban.com/people/162545416/collect?start=$0 > datss
for i in `cat type`;do
{
echo "%%%%"
read -u6
{
n=`cat datss|grep $i|wc -l`
m=`cat data |grep $i|tail -n 1|awk -F ' ' '{print $2}'`
echo '======================'
echo $n $m
echo '==================='
x=`expr $m + $n`
echo $i $x >>data
echo "" >&6
} &
}
done
done
wait
# 关闭fd6管道
exec 6>&-
b=$(date +%H%M%S)
cat data |tail -n 21 >猫仔饭
# 设置并发的进程数
thread_num=5
a=$(date +%H%M%S)
# mkfifo
tempfifo="my_temp_fifo"
mkfifo ${tempfifo}
# 使文件描述符为非阻塞式
exec 6<>${tempfifo}
rm -f ${tempfifo}
# 为文件描述符创建占位信息
for ((i=1;i<=${thread_num};i++))
do
{
echo
}
done >&6
echo "==========================="
for i in `cat type`;do
echo $i 0 >> data
done
for i in `seq 0 15 165`;do
echo $i
curl https://movie.douban.com/people/162545416/collect?start=$0 > datss
for i in `cat type`;do
{
echo "%%%%"
read -u6
{
n=`cat datss|grep $i|wc -l`
m=`cat data |grep $i|tail -n 1|awk -F ' ' '{print $2}'`
echo '======================'
echo $n $m
echo '==================='
x=`expr $m + $n`
echo $i $x >>data
echo "" >&6
} &
}
done
done
wait
# 关闭fd6管道
exec 6>&-
b=$(date +%H%M%S)
cat data |tail -n 21 >猫仔饭
echo -e "startTime:\t$a"
最后结果如下
有时间稍微优化下