linux 循环请求接口

290 阅读1分钟
engines=('ip1' 'ip2' 'ip3' 'ip4')


for ((i=0; i<4; i++))
do
        echo $i
        host=${engines[$i]}
        offer=0
        #offer=$[$i*10]
        limit=10
        filename=$1
        echo "-------------------------------"
        echo $host
        echo $offer
        echo $limit
        echo $filename

temp="www.baidu.com"

echo "--"$host"----"$offer"-----"$limit"--------" >> $filename
res=$(curl $temp)
tts_enid=$(echo $res|jq '.response.docs[].id')
score=$(echo $res|jq '.response.docs[].score')

echo $tts_enid>>$filename
echo $score>>$filename
echo "--------------">>$filename
echo "--------------">>$filename
echo "--------------">>$filename