从新浪提取上海天气的vbs

2016-01-29 17:38 16 1 收藏

从新浪提取上海天气的vbs,从新浪提取上海天气的vbs

【 tulaoshi.com - ASP 】

  起始很简单的。分析一下抓下来的代码,然后处理一下就行了。


'文件:weather.vbs 放入计划任务,每天早上8:30执行,生成饱含
'文件供首页使用
'执行方式:cscript D:上海国家会计学院网站内部社区vbsweather.vbs
'********************************************************************************************************
' Symantec ScriptBlocking Authenticated File
' E9815BB2-5813-400B-9ED5-156350335DE3

const incFilePath = "D:上海国家会计学院网站内部社区webclub" '包含文件所在目录,最后的号是必须的
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://img.jcwcn.com/attachment/portal/jcwcj/2005-12/10/05121001075035847.gif" width=172 height=17")0 then
wstr=mid(wstr,instr(wstr,"<img src="http://img.jcwcn.com/attachment/portal/jcwcj/2005-12/10/05121001075035847.gif" width=172 height=17")+len("<img src="http://img.jcwcn.com/attachment/portal/jcwcj/2005-12/10/05121001075035847.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
end if
set fs = nothing

Sub writeLog(Msg)
On Error Resume Next
Dim f
Set f = fs.OpenTextFile(logfile,8,true)
f.WriteLine now & " - " & Msg
f.close
End Sub

function getHTTPPage(url)
on error resume next
dim http
set http=createobject("MSXML2.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<4 then
exit function
end if
getHTTPPage=bytes2BSTR(Http.responseBody)
set http=nothing
if err.number<0 then err.Clear
end function

Function bytes2BSTR(vIn)
dim strReturn
dim i,ThisCharCode,NextCharCode
strReturn = ""
For i = 1 To LenB(vIn)
ThisCharCode = AscB(MidB(vIn,i,1))
If ThisCharCode < &H80 Then
strReturn = strReturn & Chr(ThisCharCode)
Else
NextCharCode = AscB(MidB(vIn,i+1,1))
strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
i = i + 1
End If
Next
bytes2BSTR = strReturn
End Function


'***********************************************
'

 

来源:https://www.tulaoshi.com/n/20160129/1502296.html

延伸阅读
丝瓜是增白、去皱的天然美容品,据医学家实验证明,长期食用丝瓜或用丝瓜液擦脸,可以让肌肤柔嫩、光滑,并可预防和消除痤疮和黑色素沉着。丝瓜中含有丰富的维他命、矿物质、植物粘液和木糖胶,因此许多精华液中都加入了丝瓜水提取物,在日本化妆品市场,这类精华液是许多女性的美容必备品。采集丝瓜水其实并不难。 1.先种丝瓜,等丝...
标签: 住房公积金
申请提取住房公积金基本条件   1、购买、建造、翻建或大修具有所有权的自住住房的。   2、偿还购房贷款本息的。   3、租房自住的。   4、离休、退休(或达到法定退休年龄) 的。   5、完全丧失劳动能力,并与所在单位终止劳动关系的。   6、出境定居的。   7、非本市户口职工与单位终止劳动关系的。...
标签: 花海天鹅
今天要学的是花海天鹅最正宗的做法。花海天鹅是一道的菜,花的时间并不多,左右,今天就教大家做这道美味健康的花海天鹅,赶快学起来吧! 天鹅苹果 健康功效 苹果:除烦、养胃、生津 食材用料 苹果一个; 小刀一把; 天鹅苹果的做法 1.准备一个苹果,用盐搓洗表面,因为现在好多黑心商家为了...
标签: 摄影
你一旦开始用镜头看世界,你会发现一切都会变得十分有趣。你随时都会察觉到你周围事物的变化。即便是日常生活中最常见的东西,大到建筑、树木,小到锅碗瓢盆、硬币、钥匙链等,在你的镜头下似乎都显现出了灵性,各领风骚。当然并不是所有的人只要拿起相机就是大师,还有很多初出茅庐的菜鸟。那么想知道如何让菜鸟变成大师吗?下面图老师小编总结...
海天酱炒花蛤 1.锅中放少许油,爆香姜丝、干红椒。 2.加入海天酱翻炒出香味。 3.加入花蛤...

经验教程

221

收藏

76
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部