偶尔还是想关注下崇高的"新闻联播"在说什么, 便用 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 点执行一次.
以下为邮箱中收到的邮件

本文介绍了一个利用Shell脚本自动抓取新闻联播内容,并通过定时任务每天21点发送邮件的技术实现,简化了获取新闻联播内容的过程。
1万+

被折叠的 条评论
为什么被折叠?



