你是否要寻找韩庚的网站,请下载FIREWORK,再打开本地址即可进入韩庚网站
May
04

如果你手机有天气预报的套餐就不用看了,我是针对没有天气预报的兄弟们准备的
首先下载一个SENDSMS的软件sendsms,然后解压到任何目录,然后解压
tar xjvf sendsms.tar.bz2
cd sendsms
make
ln -s 路径/sendsms /sbin/sendsms
上面的路径最好用全路径
然后写一个SHEEL
weather.sh

#!/bin/bash
# This script fetch user specified citys' weather forecast from
# http://weather.com.cn, and send them using a CLI SMS sender "sendsms"
# which you can get from http://share.solrex.org/dcount/click.php?id=5.
#
# You can look for new or bug fix version
# @ http://share.solrex.org/scripts/weatherman.sh.
# Copyright (C) Solrex Yang with GPL license.
#
# Usage: You should add it to crontab by “crontab -e”, and then add a line
# such as:
# 00 20 * * * /usr/bin/weatherman.sh >> ~/bin/log/weatherman.log 2>&1
# which will send weather forecast to your fetion friends at every 8pm.

CITY_LIST=(”北京”)
URL_LIST=(”101010100″)#这里是城市编码,具体你所在的城市请到http://www.weather.com.cn/查询

SMS_USER=(”飞信号码1,飞信号码2,飞信号码3″)
SMS_CITY=(”北京”)

URLBASE=”http://www.weather.com.cn/html/weather/”

get_html()
{
i=0
for city in ${CITY_LIST[*]}; do
url=$URLBASE${URL_LIST[i]}.shtml
#wget -e “http_proxy=http://user:passwd@www.phpunion.com” -O $city.txt $url
wget -nv -O $city.txt $url 2> /dev/null
i=$(($i+1))
done
}

parse_html()
{
for city in ${CITY_LIST[*]}; do
grep -q ‘”tableTop”‘ $city.txt
ISOLD=$?
if [ $ISOLD -eq 0 ]; then
grep -q ” 08:00发布)” $city.txt
# Select useful part.
IS18=$?
sed -i -e ‘1,/”tableTop”/d;/weatherYubao2/,$d;1,/风力/d;’ $city.txt
else
grep -q ” 08:00发布)” $city.txt
# Select useful part.
IS18=$?
if [ $IS18 -ne 0 ]; then
sed -i -e ‘1,/”dd_0″/d;/ddd_0/,$d;1,/风力/d;’ $city.txt
else
sed -i -e ‘1,/ch_text/d;/未来/,$d;1,/风力/d;’ $city.txt
fi
fi
# Add seperate chars
sed -i -e ’s$

  • $
  • \n

  • $g’ $city.txt
    # Remove HTML tags and empty lines.
    sed -i -e ’s/<[^>]*>//g;/ sed -i -e ’s/ //g;s/°C//g;s/^\s*//g;/^$/d’ $city.txt
    # Cut verbose words.
    sed -i -e ’s/无持续风向/轻/g;s/℃/度/g;s/星期/周/g;s/\r//g;’ $city.txt
    #continue
    # Format file content to SMS.
    LINES=(`cat $city.txt`)
    COUNT=0
    if [ ${ISOLD} -eq 0 ]; then
    if [ ${IS18} -ne 0 ]; then
    MES=”${city}(18:00发布)\n”
    MES=$MES${LINES[$((COUNT++))]}:
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]}’.\n’
    else
    MES=”${city}(8:00发布)\n”
    fi
    MES=$MES${LINES[$((COUNT++))]}:
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]}’;’
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]}’.\n’
    MES=$MES${LINES[$((COUNT++))]}:
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]}’;’
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]}’.\n’
    else
    if [ ${IS18} -ne 0 ]; then
    MES=”${city}(18:00发布)\n”
    MES=$MES${LINES[$((COUNT++))]}:
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]},
    MES=$MES${LINES[$((COUNT++))]}${LINES[$((COUNT++))]}’.\n’
    else
    MES=”${city}(8:00发布)\n”
    fi
    MES=$MES${LINES[$((COUNT++))]}:
    MES=$MES${LINES[$((COUNT))]}${LINES[$((COUNT+2))]},
    MES=$MES${LINES[$((COUNT+4))]},
    MES=$MES${LINES[$((COUNT+6))]}${LINES[$((COUNT+8))]}’;’
    MES=$MES${LINES[$((COUNT+1))]}${LINES[$((COUNT+3))]},
    MES=$MES${LINES[$((COUNT+5))]},
    MES=$MES${LINES[$((COUNT+7))]}${LINES[$((COUNT+9))]}’.\n’
    COUNT=$((COUNT+10))
    MES=$MES${LINES[$((COUNT++))]}:
    MES=$MES${LINES[$((COUNT))]}${LINES[$((COUNT+2))]},
    MES=$MES${LINES[$((COUNT+4))]},
    MES=$MES${LINES[$((COUNT+6))]}${LINES[$((COUNT+8))]}’;’
    MES=$MES${LINES[$((COUNT+1))]}${LINES[$((COUNT+3))]},
    MES=$MES${LINES[$((COUNT+5))]},
    MES=$MES${LINES[$((COUNT+7))]}${LINES[$((COUNT+9))]}’.\n’
    fi
    echo -ne $MES > $city.txt
    done
    }send_forcast()
    {
    i=0
    for user in ${SMS_USER[*]}; do
    sendsms -vlf 你的手机号-p 你的密码 -t ${SMS_USER[$i]} < ${SMS_CITY[$i]}.txt
    sleep 1
    i=$(($i+1))
    done
    }clear_html()
    {
    for city in ${CITY_LIST[*]}; do
    rm -f $city.txt
    done
    }get_html
    parse_html
    send_forcast
    clear_html
    然后通过CRONTAB做个计划任务

    crontab -e
    00 18 * * * /bin/bash /root/weather.sh

    我把weather.sh放在ROOT目录了,顺便留个下载地址weatherman.sh 根据你放置自己设置
    好了,每天18点等着自己的飞信给你发天气预报吧

    本教程来源互联网,个人总结了一下,如需转载,请保留原信息:http://www.phpunion.com

    对了
    最后说明一下,飞信号码必须为你的好友,

  • No Responses

    Comments are closed.