crontab + jq + jtab 百度统计
每日发送百度统计数据
前言
为方便查看百度统计数据,此方法可以方便查看统计昨天访问数据。
准备
安装jq
格式化JSON插件,把获取到的数据JSON格式化处理
yum -y install jq
test
curl -s --request GET 'https://ms.busyhe.cn/bdtj/projects/yesterday' | jq
安装jtab
brew tap wlezzar/jtab https://github.com/wlezzar/jtab
brew install wlezzar/jtab/jtab
jtab --help
centos
cargo install --git https://github.com/wlezzar/jtab
格式化
curl -s --request GET 'https://ms.busyhe.cn/bdtj/projects/yesterday' | jq '. | .result' | jtab --take 6 -f site_id -f domain -f pv_count -f visitor_count -f ip_count -f avg_visit_time
crontab
此命令为每天定时发送统计邮件
crontab -e
输入
MAILTO=busyhe@qq.com
0 9 * * * curl -s --request GET 'https://ms.busyhe.cn/bdtj/projects/yesterday' | jq '. | .result' | /root/.cargo/bin/jtab --take 6 -f site_id -f domain -f pv_count -f visitor_count -f ip_count -f avg_visit_time
本文系作者 @busyhe 原创发布在 BusyHe-Blog。未经许可,禁止转载。