How to use server curl to simulate postman login and download under linux?
For work requirements, you need to export a report at a fixed time every day, but because you need to log in first, use the server curl to simulate the download, as shown below:
#! / bin/bashcurdate= `date +% Ymure% mmury% d` # get tokena= `curl-H "Content-Type:application/json"-d'@ 1.json' http://x.x.x.x/ua/login`token=`echo $a first | awk-F '{print $2}' | awk-F:'{print $2}'| awk-F\ "'{print $2}'`# Export region GetArea () {curl-o Area 'http://x.x.x.x/s1mca2iot-epidemicm11anage/e1pide1micsituationdailygg/exportAreaStatistic'-H' Accept-Encoding: gzip, deflate'-H 'Accept-Language: zh,en Qcoach 0.9-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 Text/plain, * / *'- H 'Connection: keep-alive'-H "token: $token"-- compressed} GetAreasleep 3exportExcelWithAreasleep 30