现在的位置: 首页 > 综合 > 正文

订阅”新闻联播”文字标题到邮箱

2013年08月01日 ⁄ 综合 ⁄ 共 519字 ⁄ 字号 评论关闭

偶尔还是想关注下崇高的"新闻联播"在说什么, 便用 shell 写了个抓取文字标题发送到邮箱的脚本. 如下:

#!/bin/sh
#author: dengzhaoqun
#date: 2013-01-29

tmp_file="/tmp/tmp_xm_update_xwlb"
tmp_mail="/tmp/tmp_xm_update_xwlb_mail"
url="http://cctv.cntv.cn/lm/xinwenlianbo/`date +%Y%m%d`.shtml"
curl -o $tmp_file $url
echo `date +%Y-%m-%d`> $tmp_mail
echo >>$tmp_mail
cat $tmp_file | grep "new title_array_01('" | sed s/^.*title_array_01\(\'// | sed s/\',\'.*$// | sed '1d' >> $tmp_mail
mail -s "新闻联播" 123456@qq.com -- -f "dzq_lenovo_bt@bt.foo.org"<$tmp_mail

然后在 crontab 中添加

0 21 * * * xm_update_xwlb.sh

让脚本每天 21 点执行一次. 

以下为邮箱中收到的邮件

抱歉!评论已关闭.