shell

使用shell脚本批量发送curl的POST数据请求

星期五, 十月 18th, 2019 | JAVA-and-J2EE, linux | 没有评论

里面写了sleep睡眠,可以移除

写定循环传递参数等,用于自动处理数据比较方便,记录如下,可以根据自己的情况进行调整.

shell脚本如下

#!/bin/bash
function curlRequest()
{
	echo ">>>>>>>>>>>>>>"$1
    info=`curl -s -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "{\"id\":$1,\"processState\":3}" "https://www.pomelolee.com/info" `
 
    echo "<<<<<<<<<<<<<<"$info
    #info=`curl -s -m 10 --connect-timeout 10 -I $1`
    #code=`echo $info|grep "HTTP"|awk '{print $2}'`
    #if [ "$code" == "200" ];then
    #    echo "request succeed,ret code is $code"
    #else
    #    echo "request fail,ret code is $code"
    #fi
}
 
ids=(29 100 13 8 91 44)
for id in ${ids[@]}
do
  curlRequest $id
  echo $id
  sleep 2s
done

Tags:

Search

文章分类

Links

Meta