linux下如何使用服务器curl模拟postman登录和下载?
工作需求,需要每日定时导出一个报表,但是由于要先登录,所以使用服务器curl模拟下载,具体如下:
创新互联是一家专业提供临汾企业网站建设,专注与成都网站设计、做网站、H5技术、小程序制作等业务。10年已为临汾众多企业、政府机构等服务。创新互联专业网站建设公司优惠进行中。
#!/bin/bash
curdate=`date +%Y-%m-%d`
#先获取token
a=`curl -H "Content-Type:application/json" -d '@1.json' http://x.x.x.x/ua/login`
token=`echo $a|awk -F , '{print $2}' |awk -F : '{print $2}' |awk -F \" '{print $2}'`
#导出区域
GetArea() {
curl -o Area 'http://x.x.x.x/s1mca2iot-epidemicm11anage/e1pide1micsituationdailygg/exportAreaStatistic' -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh,en;q=0.9,ja;q=0.8,zh-TW;q=0.7,fr;q=0.6,zh-CN;q=0.5' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'Connection: keep-alive' -H "token: $token" --compressed
}
exportExcelWithArea() {
curl -o exportExcelWithArea "http://x.x.x.x/sss33mcccaiot-epid1emic2man1a1ge/epi2demic1situationdailygg/exportExcelWithArea?currentDay=$curdate" -H 'Accept-Encoding: gzip, deflate' -H 'Accept-Language: zh,en;q=0.9,ja;q=0.8,zh-TW;q=0.7,fr;q=0.6,zh-CN;q=0.5' -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.75 Safari/537.36' -H 'Accept: application/json, text/plain, */*' -H 'Connection: keep-alive' -H "token: $token" --compressed
}
GetArea
sleep 3
exportExcelWithArea
sleep 30
新闻标题:linux下如何使用服务器curl模拟postman登录和下载?
文章出自:http://lswzjz.com/article/jgsjeg.html