shell脚本抓取网页信息

利用shell脚本分析网站数据

# define url
time=$(date +%F)
mtime=$(date +%T)
file=/abc/shell/abc/abc_$time.log
http=https://abc.com/abc/abc.do
key='tender_sum'

log_file=/abc/shell/abc/remind.log
check_log=/abc/shell/abc/check.log

function Mail(){
    mail -s "抓取成功" 88888888@qq.com < $log_file
}

curl -d "user=abc&password=123" $http > $file 
echo $?

#抓第一段数组

name=`awk -F ',' '{print $13":"$32}' $file | awk -F ':' '{print $4}'`
echo "name=$name"

tender_sum=`awk -F ',' '{print $13":"$32}' $file | awk -F ':' '{print $2}'`
echo "tender_sum=$tender_sum"

borrow_sum=`awk -F 'borrow_sum' '{print $2}' $file | awk -F '[: ,]' '{print $2}'`
echo "borrow_sum=$borrow_sum"
flag=1
#如果有一个名字跟他相等,说明没有新的内容
for title in `cat project_title.log`
    do
        if [ $name == $title ]
            then
                flag=0
        fi
    done

#出现了新的内容,判断是否满足条件,是则发邮件通知,并且将标题写入project_title.log
if [ $flag == 1 ]
    then
        if [ $tender_sum == $borrow_sum ]
            then
                echo "内容$name已经更新成功,请登录网站查看^_^" > $log_file
                Mail
                echo $name >> project_title.log
            else
                echo "内容$name更新进度:已更新-- $tender_sum --$mtime--" >> $check_log 
        fi
    else
        echo "没有新的内容" >> $check_log
fi
    

 

转载于:https://www.cnblogs.com/taiguyiba/p/6373102.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值