iphone自动下载当天VOA

前面一篇文章也是下载VOA,但是由于iphone cron不能在休眠时用而需要配合电脑才能下载。
后来研究了一下iphone的启动步骤,发现可以在/System/Library/LaunchDaemons添加定时job.所以整个iphone自动下载当天VOA设置如下:
1.脚本: /var/mobile/sh/getVoa.sh

cd /var/mobile/voa/
today=`date +%m-%d|sed 's/^0\+//'|sed 's/-0/-/'`
mkdir $today
cd $today
`wget -O voa.html http://www.51voa.com/`
domain="http://www.51voa.com"
urlList=`sed 's/"/\n/g' /var/mobile/voa/$today/voa.html | grep -C 4 $today |grep "\(VOA_Special_English\)\|\(VOA_Standard_English/\)\|\(Voa_English_Learning\)/.*html"`
echo $urlList
for i in $urlList
do
`wget -O temp.html ${domain}${i}`
mp3=`sed 's/"/\n/g' /var/mobile/voa/$today/temp.html | grep "/path.asp?url"`
echo "------------------$mp3"
if [ -n "$mp3" ]; then
echo $mp3
`wget $domain$mp3 --content-disposition`
fi
lrc=`sed 's/\("\|><\|href=\)/\n/g' /var/mobile/voa/$today/temp.html| grep \.lrc|awk '{print $1}'|sed 's/img//g'`
echo "------------------$lrc"
if [ -n "$lrc" ]; then
echo $lrc
`wget $domain$lrc --content-disposition`
fi
done
rm *html


2./System/Library/LaunchDaemons添加文件 com.downvoa.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.downvoa</string>
<key>ProgramArguments</key>
<array>
<string>/var/mobile/sh/getvoa.sh</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>22</integer>
<key>Minute</key>
<integer>55</integer>
</dict>
<key>UserName</key>
<string>root</string>
</dict>
</plist>


3.加载此文件:launchctl load com.downvoa.plist

那么每晚的22:55分iphone4就会去下载当天的voa,保存在/var/mobile/sh/{月-日} 的文件夹下。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值