其实很简单的。分析一下抓下来的代码,然后处理一下就行了。
'文件:weather.vbs 放入计划任务,每天早上8:30执行,生成饱含
'文件供首页使用
'执行方式:cscript D:\上海国家会计学院网站\内部社区\vbs\weather.vbs
'********************************************************************************************************
' Symantec scriptBlocking Authenticated File
' E9815BB2-5813-400B-9ED5-156350335DE3
const incFilePath = "D:\上海国家会计学院网站\内部社区\web\club\" '包含文件所在目录,最后的\号是必须的
const logfile = "d:\club-job-log.txt" '日志文件
const incWeather = "weather-report.asp" '包含文件所在目录,最后的\号是必须的
dim fs
dim f
on error resume next
Set fs = CreateObject("scripting.FileSystemObject")
dim wstr
wstr=getHTTPPage("
http://sh.sina.com.cn/";)
'Response.Write wstr
if instr(wstr,"<img src=http://www.newasp.net/Article/asp/technique/2005/images/sina_sh/new/sh24.gif width=172 height=17>")>0 then
wstr=mid(wstr,instr(wstr,"<img src=http://www.newasp.net/Article/asp/technique/2005/images/sina_sh/new/sh24.gif width=172 height=17>")+len("<img src=http://www.newasp.net/Article/asp/technique/2005/images/sina_sh/new/sh24.gif width=172 height=17>"))
wstr=mid(wstr,instr(wstr,"<table width=160 border=0 cellspacing=0 cellpadding=0>"))
wstr=mid(wstr,1,instr(wstr,"</table>")+len("</table>"))
end if
wstr=replace(wstr,"<tr><td colspan=3 align=right><a href=http://weather.sina.com.cn/>其他城市</a><font color=#015B7B>>></font></td></tr>","")
dim pos1,pos2
pos1=instr(wstr,"<tr>")
pos2=instr(pos1,wstr,"</tr>")
wstr=right(wstr,len(wstr)-pos2-4-4)
wstr=replace(wstr,"</table>","")
wstr=replace(wstr,"width=35","")
wstr=replace(wstr,"width=45","")
wstr=replace(wstr,"width=60","")
'Response.Write wstr
if err.number=0 then
Set f = fs.CreateTextFile(incFilePath & incWeather,true)
f.write wstr
set f = nothing
else
wscript.echo err.description<br>
end if<br>
set fs = nothing<br>
<br>
Sub writeLog(Msg)<br>
On Error Resume Next<br>
Dim f<br>
Set f = fs.OpenTextFile(logfile,8,true)<br>
f.WriteLine now & " - " & Msg<br>
f.close<br>
End Sub<br>
<br>
function getHTTPPage(url)<br>
on error resume next<br>
dim http<br>
set http=createobject("MSXML2.XMLHTTP")<br>
Http.open "GET",url,false<br>
Http.send()<br>
if Http.readystate<>4 then <br>
exit function<br>
end if<br>
getHTTPPage=bytes2BSTR(Http.responseBody)<br>
set http=nothing<br>
if err.number<>0 then err.Clear <br>
end function<br>
<br>
Function bytes2BSTR(vIn)<br>
dim strReturn<br>
dim i,ThisCharCode,NextCharCode<br>
strReturn = ""<br>
For i = 1 To LenB(vIn)<br>
ThisCharCode = AscB(MidB(vIn,i,1))<br>
If ThisCharCode < &H80 Then<br>
strReturn = strReturn & Chr(ThisCharCode)<br>
Else<br>
NextCharCode = AscB(MidB(vIn,i+1,1))<br>
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))<br>
i = i + 1<br>
End If<br>
Next<br>
bytes2BSTR = strReturn<br>
End Function <br>
<br>
<br>
'***********************************************<br>
' <br>
<br>
<br>
</font><br></div>
<div></div>
</div><div id="Message" class="Message"></div></font></div>
<script type="text/javascript">
document.body.oncopy = function () { setTimeout( function () { var text = clipboardData.getData("text"); if (text) { text = text + "\r\n本篇文章来源于 中国建站之家 原文链接:"+location.href; clipboardData.setData("text", text); } }, 100 ) }
</script>
<br>
<a href="javascript:window.open('http://shuqian.qq.com/post?from=3&title='+encodeURIComponent(document.title)+'&uri='+encodeURIComponent(document.location.href)+'&jumpback=2&noui=1','favit','width=930,height=470,left=50,top=50,toolbar=no,menubar=no,location=no,scrollbars=yes,status=yes,resizable=yes');void(0)" style="text-decoration:none;color:#155da5;display:block;background:url('http://shuqian.qq.com/img/add.gif') no-repeat 0px 0px;height:23px;width:300px;padding:2px 2px 0px 20px;font-size:14px;">将本文收藏到QQ书签与更多好友分享</a>
<div></div>
</td>
<table width="575" border="0" cellpadding="0" cellspacing="0">
<tr>
</tr>
<tr>
<td align="right" height=25 bgcolor=#F7F7F7 >
<script language=javascript src=/wz/sg.JS></script>
[<a href=javascript:window.print()>打 印</a>]
</tr>
</table>
<table width="575" border="0" cellpadding="0" cellspacing="0">
<tr>
</tr>
<tr>
<td align="right" height=25 bgcolor=#F7F7F7 style="display:block;padding:0px 10px">
<font color=#000000>[<script language=JavaScript src="/Article/Hits.Asp?ArticleID=5547"></script>]</font>
[<a href="javascript:history.go(-1)">返回上一页</a>]
[<a href="/user/favorite.asp?action=add&topic=一个例子:从新浪提取上海天气的vbs">收 藏</a>]</td>
</tr>
<tr>
<table width="575" border="0" cellpadding="0" cellspacing="0">
<tr>
</tr>
<tr>
<td style="display:block;padding:0px 10px"><div><font color=#000000>上一篇文章:</font><a href=/Article/10/130/2005/200507205546.html>将你的网站设置为客户的信任站点--VB方案</a></div><div><font color=#000000>下一篇文章:</font><font color=#000000><a href=/Article/10/131/2005/200507205548.html>用Visual C#开发WinForm的应用程序</a></font></div></td>
</tr>
</table>
<table width="575" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="titlebg1">∷相关文章评论∷ (评论内容只代表网友观点,与本站立场无关!) [<a href=/Article/comment.asp?ArticleID=5547 target=_blank>更多评论</a>...]</td>
</tr>
<tr valign="top">
<td></td>
</tr>
</table>
</td>
<td width="188" class="tableleft"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="titleback1">精彩推荐</td>
</tr>
<tr>
<td height="260" valign="center" class="showbody1"><script language=javascript src=/ad/180601.js></script></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="titleback1">热门文章</td>
</tr>
<tr>
<td height="100" valign="top" class="showbody1"><table width="100%" border="0" cellpadding="2" cellspacing="0"><tr>
<td class="showlist11">· <a href='/Article/10/138/2005/200507256912.html' class="showlist" title="注册码大全二">注册码大全二</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/10/138/2005/200507256914.html' class="showlist" title="注册码大全四">注册码大全四</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/10/138/2005/200507256911.html' class="showlist" title="注册码大全一">注册码大全一</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/196/197/2005/2005081911736.html' class="showlist" title="要10G免费网络硬盘的请进来!">要10G免费网络硬盘的请进..</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/206/2007/2007030319347.html' class="showlist" title="通过google 赶快来赚美金">通过google 赶快来赚美金..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/10/138/2005/200507256919.html' class="showlist" title="注册码大全十">注册码大全十</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/14/253/2005/2005092114218.html' class="showlist" title="头像-qq头像(qq新头像)4">头像-qq头像(qq新头像)4..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/13/150/2006/2006022316028.html' class="showlist" title="让你轻松架设FTP服务器1">让你轻松架设FTP服务器1..</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/10/138/2005/200507256913.html' class="showlist" title="注册码大全三">注册码大全三</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/14/244/2005/2005092014121.html' class="showlist" title="梦幻背景图片7">梦幻背景图片7</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/14/249/2005/2005092114181.html' class="showlist" title="卡通动物图片6">卡通动物图片6</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/14/269/2005/2005092114241.html' class="showlist" title="网页制作素材-按钮素材2">网页制作素材-按钮素材2..</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/13/150/2006/2006022316032.html' class="showlist" title="让你轻松架设FTP服务器5">让你轻松架设FTP服务器5..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/14/244/2005/2005092014153.html' class="showlist" title="风景图片8">风景图片8</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/10/138/2005/200507256918.html' class="showlist" title="注册码大全九">注册码大全九</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/13/150/2006/2006022316029.html' class="showlist" title="让你轻松架设FTP服务器2">让你轻松架设FTP服务器2..</a></td>
<td class="showlist12"></td>
</tr></table></td>
</tr>
<tr>
<td height="2" bgcolor="#FFFFFF"></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="titleback1">关注此文读者还看过</td>
</tr>
<tr>
<td height="100" valign="top" class="showbody1"><table width="100%" border="0" cellpadding="2" cellspacing="0"><tr>
<td class="showlist11">· <a href='/Article/10/133/2005/200507216411.html' target="_blank" class="showlist" title="如何避免表单的重复提交">如何避免表单的重复提交..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/10/133/2005/200507216179.html' target="_blank" class="showlist" title="PHP的十个高级技巧(上)">PHP的十个高级技巧(上)</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/10/133/2005/200507309385.html' target="_blank" class="showlist" title="BBS(php & mysql)完整版(四)">BBS(php & mysql)完..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/223/292/2006/2006011815545.html' target="_blank" class="showlist" title="Google“倒卖”传统报纸广告的三大猜想">Google“倒卖”传统报纸..</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/13/151/2005/200507204570.html' target="_blank" class="showlist" title="Webmail攻防实战(3)">Webmail攻防实战(3)</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/10/310/2007/2007032519545.html' target="_blank" class="showlist" title="AJAX技术三特征解析">AJAX技术三特征解析</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/11/139/2005/200507194411.html' target="_blank" class="showlist" title="DreamWeaver,经典50问(4)">DreamWeaver,经典50问(4..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/223/291/2006/2006071416836.html' target="_blank" class="showlist" title="收缩企业软件部门之后 百度转攻精准广告模式">收缩企业软件部门之后 百..</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/10/130/2005/2005091813581.html' target="_blank" class="showlist" title="如何用asp把sql server數據轉化為execl文件">如何用asp把sql server數..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/10/134/2006/2006112518195.html' target="_blank" class="showlist" title="IE中实现全屏广告代码">IE中实现全屏广告代码</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/11/140/2006/2006071316817.html' target="_blank" class="showlist" title="Flash 9预览版AS 3.0编程新特性体验1">Flash 9预览版AS 3.0编程..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/10/135/2005/200507181219.html' target="_blank" class="showlist" title="用代码“写”出扫描线效果图片">用代码“写”出扫描线效..</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/10/131/2005/2005091512533.html' target="_blank" class="showlist" title="VB.NET中的面向对象编程特征">VB.NET中的面向对象编程..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/223/290/2006/2006012215633.html' target="_blank" class="showlist" title="梦想再次冲动:可否在手机上复制一个Google?">梦想再次冲动:可否在手..</a></td>
<td class="showlist12"></td>
</tr><tr>
<td class="showlist11">· <a href='/Article/13/150/2005/200507204503.html' target="_blank" class="showlist" title="LINUX学习笔记--FTP服务器设置篇2">LINUX学习笔记--FTP服务..</a></td>
<td class="showlist11"></td>
</tr><tr>
<td class="showlist12">· <a href='/Article/10/133/2005/200507309414.html' target="_blank" class="showlist" title="用PHP制作静态网站的模板框架(四)">用PHP制作静态网站的模板..</a></td>
<td class="showlist12"></td>
</tr></table></td>
</tr>
</table>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="titleback1">相关文章</td>
</tr>
<tr>
<td height="100" valign="top" class="showbody1">· <a href="/Article/10/133/2007/2007062120525.html" title='动态网页技术PHP和JS实现交互的一个例子'>动态网页技术PHP和JS实现交..</a><br>
· <a href="/Article/10/130/2007/2007032719582.html" title='在ASP页里面注册DLL的VBScript CLASS'>在ASP页里面注册DLL的VBScr..</a><br>
· <a href="/Article/10/130/2005/2005092013931.html" title='清空iis log 中自己登录ip的vbs'>清空iis log 中自己登录ip的..</a><br>
· <a href="/Article/10/130/2005/2005091713369.html" title='通过表单创建word的一个例子'>通过表单创建word的一个例子..</a><br>
· <a href="/Article/10/130/2005/2005091613080.html" title='在ASP页里面注册DLL的VBScript CLASS'>在ASP页里面注册DLL的VBScr..</a><br>
· <a href="/Article/10/130/2005/2005091613038.html" title='从新浪提取上海天气的vbs'>从新浪提取上海天气的vbs</a><br>
· <a href="/Article/10/133/2005/200507309010.html" title='PHP 存取 MySQL 数据库的一个例子'>PHP 存取 MySQL 数据库的一..</a><br>
· <a href="/Article/10/130/2005/200507288764.html" title='Dom遍历XML的一个例子,结果为树状结构'>Dom遍历XML的一个例子,结果..</a><br>
· <a href="/Article/10/130/2005/200507288561.html" title='断开的数据库连接的一个例子'>断开的数据库连接的一个例子..</a><br>
· <a href="/Article/10/133/2005/200507216128.html" title='PHP操作excel的一个例子(原创)'>PHP操作excel的一个例子(原..</a><br>
· <a href="/Article/10/137/2005/200507181997.html" title='一个用Wsh来控制SqlServer的Dcom的VBs'>一个用Wsh来控制SqlServer的..</a><br>
· <a href="/Article/10/130/2005/20050718570.html" title='实现支持逻辑搜索/单词搜索/词组搜索+支持OR/AND关键字的VBS CLASS'>实现支持逻辑搜索/单词搜索..</a><br>
· <a href="/Article/10/130/2005/20050717281.html" title='清空iis log 中自己登录ip的vbs'>清空iis log 中自己登录ip的..</a><br></td>
</tr>
</table>
</td>
</tr>
</table>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder">
<tr>
<td height="3"></td>
</tr>
</table>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder">
<tr>
<td height="23" align="right">
<table width="100%" border="0" cellspacing="0" class="tablebody8" cellpadding="0">
<tr>
<td height="5"></td>
</tr>
<tr>
<td height="23" align="right" valign="middle"><center><a href="/support/about.asp" class="navmenu2">关于本站</a> -
<a href="/support/help.asp" class="navmenu2">网站帮助</a> -
<a href="/support/advertise.asp" class="navmenu2">广告合作</a> -
<a href="/support/declare.asp" class="navmenu2">下载声明</a> -
<a href="/link/" target="_blank" class="navmenu2">友情连接</a> -
<a href="/support/sitemap.asp" class="navmenu2">网站地图</a> -
<a href="#" target="_blank" class="navmenu2">人才招聘</a>
</tr>
</table></td>
</tr>
<tr>
<td height="1"></td>
</tr>
</table>
<table width="778" border="0" align="center" cellpadding="0" cellspacing="0" class="tableborder">
<tr>
<td height="60" align="center" class="tablebody1">网站合作、内容监督、商务咨询:QQ: 9576619
<br>
Copyright ? 2005--2008 中国建站之家版权所有
<br><a href="http://www.miibeian.gov.cn" target="_blank" title="粤ICP备05092265号"><font color=#000000>粤ICP备05092265号
</font><br><script src='http://s6.cnzz.com/stat.php?id=44148&web_id=44148&show=pic' language='JavaScript' charset='gb2312'></script> </td>
<script language="javascript" src="/inc/Std_StranJF.Js"></script>
</table>
</body>
</html>
<span id="naruco_ad_body" style="display:none;">
<script language=javascript src=/adfile/top.js></script>
</span>
<script type="text/javascript">
var naruco_ad = document.getElementById('naruco_ad');
if (naruco_ad != null) {
naruco_ad.innerHTML=naruco_ad_body.innerHTML;
naruco_ad_body.innerHTML="";
}
</script>