script1234567891011121314151617181920212223242526272829303132333435363738394041424344#!/bin/bash # This is the basic bash script export LANG=zh_CN.UTF-8request_date=`date`request_log=/home/byzhao/baidu_log.logecho "下载目录"curl https://byzhao.cn/post-sitemap.xml -o /home/byzhao/output.xmlecho "解析文档....."xpath -q -e '//url/loc/text()' /home/byzhao/output.xml | tee /home/byzhao/urls.txtperl -p -i -e "s/endless-zby.github.io/www.byzhao.cn/g" /home/byzhao/urls.txtecho "同步至百度收录平台....."request_code=`curl -s -H 'Content-Type:text/plain' --data-binary @/home/byzhao/urls.txt "http://data.zz.baidu.com/urls?site=www.byzhao.cn&token=XXXXXXXXX" | jq`echo "$request_code" >> $request_logrequest_code2=`echo "$request_code" | grep success`echo "$request_code2" >> $request_logif [[ "$request_code2" == *success* ]] then request_message=`echo -e "$request_date \t 推送成功\n$request_code\n"` echo "$request_message" >> $request_log echo "$request_message" # 发送消息到手机 remain=`echo $request_code | jq '.remain'` success_no=`echo $request_code | jq '.success'` echo "$remain" >> $request_log message=`curl -X "POST" "http://xxxx.xxxxxx.cn:xxxx/message/push" -H 'Content-Type: application/json;charset=utf-8' -d '{"text":"百度收录同步成功","desp":"### 百度收录同步成功 \n- 剩余推送数量:'$remain' \n- 本地推送数量:'$success_no'","pushkey":"PDU1TtRhwbxSrMmJ38D4aPOduQdG82WcXOHVa"}' | jq` echo "$message" else request_message=`echo -e "$request_date \t 推送异常\n$request_code\n"` echo "$request_message" >> $request_log echo "$request_message"fi