每天给自己通过telegram和微信自动推送当前的btc/eth价格

Tags:

#!/bin/bash
i=`curl -s https://api.huobi.pro/market/detail/merged?symbol=btcusdt | sed 's/,/\n/g' | grep "ask" | sed 's/:/\n/g' | sed '1d' | sed 's#\[#\n#g' | sed 's#\:#\n#g'`

j=`curl -s https://api.huobi.pro/market/detail/merged?symbol=ethusdt | sed 's/,/\n/g' | grep "ask" | sed 's/:/\n/g' | sed '1d' | sed 's#\[#\n#g' | sed 's#\:#\n#g'`

b="40000";

msg=''

if [ `expr $i \> $b` -eq 0 ];then
msg="ETH=$j | BTC$i,小于${b}USDT"
else
msg="ETH=$j | BTC$i,大于${b}USDT"
fi

echo $msg

curl -G \
    --data-urlencode "text=$msg" \
    https://api.telegram.org/bot<id>....zLY8hTbqfzo/sendMessage?chat_id=-10...350
    # http://example.com?p1=value%201&p2=value%202

curl -G \
    --data-urlencode "text=$msg" \
    https://sc.ftqq.com/SCU<key>...6b16.send
    # http://example.com?p1=value%201&p2=value%202
chmod +x /data/daily_btc_price/daily_btc_price.sh

crontab -e
# everyday 0830am - send price of btc/eth
30 08 * * *  /data/daily_btc_price/daily_btc_price.sh

Leave a Reply