飞信批处理应用--每日定时发送天气预报及消息

需要用到的工具有wget,fetion,fetion支持包等。所有文件放在一个文件夹下,然后运行批处理sendweather.bat或fetion.bat
主要代码如下:
sendweather.bat
@echo off
wget -q -O temp.txt http://minisite.qq.com/Weather/index.html
findstr "深圳" temp.txt>temp1.txt
for /f "eol=< tokens=2,3* delims=, " %%i in (temp1.txt) do @echo %%i %%j %%k %%l>temp2.txt
for /f "tokens=3,4,5,6,7 delims=, " %%i in (temp2.txt) do (
set date=%%i
set weather=%%j
set low=%%k
set high=%%l
)
echo   今天是:%date:~1,6% && echo 今天是:%date:~1,6%>%date%天气.txt
echo 今日天气:%weather:~1,5% && echo 今日天气:%weather:~1,5%>>%date%天气.txt 
echo 最低温度:%low:~1,2%℃ && echo 最低温度:%low:~1,2%℃>>%date%天气.txt
echo 最高温度:%high:~1,2%℃ &&echo 最高温度:%high:~1,2%℃ >>%date%天气.txt
del temp1.txt 
del temp2.txt
del temp.txt
echo 按任意键发送今日天气!
pause>nul
set weath=今天是:%date:~1,6%,今日天气:%weather:~1,5%,最低气温:%low:~1,2%℃,最高气温:%high:~1,2%℃.
set /a a=0
for /f %%i in (phone.txt) do (
fetion --mobile=1342874#### --pwd=******** --to=%%i --msg-gb=%weath%
set /a a=a+1
)
set a:
set weath:
echo   恭喜你,%a%条信息发送成功!

升级版本
fetion.bat
@echo off
:begin
cls
color 02
echo            #####################飞信多功能应用#########################
echo.
echo                           1.查看并新增通讯录
echo                           2.给指定好友发送短信息
echo                           3.给通讯录中的所有好友群发信息
echo                           4.向所有好友发送今日天气信息
echo                           5.退出
echo.
echo            ############################################################
set /p
set /p id=请输入选项(1/2/3/4/5):
if %id%==1 goto a
if %id%==2 goto b
if %id%==3 goto c
if %id%==4 goto d
if %id%==5 goto end
:a
set /p ph=请输入要增加的号码:
echo %ph%>>phone.txt
type phone.txt
echo    添加联系人成功!
set id=
set /p answer=继续添加请按1,返回主菜单请按回车键:
if %answer%==1 goto a
goto begin
:b
set /p ph=请输入联系人电话:
set /p file=请输入你想说的话:
fetion --mobile=1342####### --pwd=******** --to=%ph% --msg-gb=%file%
echo   恭喜你,短信发送成功!
set ph=
set /p answer=继续发送请按1,返回主菜单请按回车键:
if %answer%==1 goto b
goto begin
:c
set /p file=请输入你想说的话:
set /a a=0
for /f %%i in (phone.txt) do (
fetion --mobile=134287##### --pwd=******** --to=%%i --msg-gb=%file%
set /a a=a+1
)
echo   恭喜你,%a%条信息发送成功!
set file=
set /p answer=继续发送请按1,返回主菜单请按回车键:
if %answer%==1 goto c
goto begin
:d
wget -q -O temp.txt http://minisite.qq.com/Weather/index.html
findstr "深圳" temp.txt>temp1.txt
for /f "eol=< tokens=2,3* delims=, " %%i in (temp1.txt) do @echo %%i %%j %%k %%l>temp2.txt
for /f "tokens=3,4,5,6,7 delims=, " %%i in (temp2.txt) do (
set date=%%i
set weather=%%j
set low=%%k
set high=%%l
)
echo   今天是:%date:~1,6% && echo 今天是:%date:~1,6%>%date%天气.txt
echo 今日天气:%weather:~1,5% && echo 今日天气:%weather:~1,5%>>%date%天气.txt 
echo 最低温度:%low:~1,2%℃ && echo 最低温度:%low:~1,2%℃>>%date%天气.txt
echo 最高温度:%high:~1,2%℃ &&echo 最高温度:%high:~1,2%℃ >>%date%天气.txt
del temp1.txt 
del temp2.txt
del temp.txt
echo 按任意键发送今日天气!
pause>nul
set weath=今天是:%date:~1,6%,今日天气:%weather:~1,5%,最低气温:%low:~1,2%℃,最高气温: 

%high:~1,2%℃.
set /a a=0
for /f %%i in (phone.txt) do (
fetion --mobile=1342####### --pwd=********** --to=%%i --msg-gb=%weath%
set /a a=a+1
)
set a:
set weath:
echo   恭喜你,%a%条信息发送成功!
echo 按任意键返回主菜单
pause
goto begin
:end

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章