curl_login

作者: siediyer 分类: linux 发布时间: 2013-06-09 15:36
#!/bin/bash

USERNAME=username
PASSWORD=password
LOGINURL=http://www.example.com/login
UPDATEURL=http://www.example.com/update
LOGFILE=update.log
# cookie temp file
COOKIEFILE=cookie_tmp.txt

# login
# -d your login information
# -c save cookie to a temp file
# -s silence mode
curl $LOGINURL -d"username=$USERNAME&password=$PASSWORD&autologin=1" -c $COOKIEFILE -s

# update
# -b use the cookie file
RESPONSE=`curl $UPDATEURL -s -b $COOKIEFILE |grep $USERNAME`
TIME=`date +'%Y-%m-%d %H:%M:%S'`
# write the response to log file
echo "$TIME | $RESPONSE" >> $LOGFILE
# delete cookie temp file
rm $COOKIEFILE

 

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!

Title - Artist
0:00