- '////code by youxi01@bbs.bathome.net
- '////初期作品;
- '////这里获取的天气预报是本人所在的城市的天气预报;
- '////原理:小偷程序,分析当地气象部门网页,然后截取相关内容
- dim http,length,fso, f
- function connect()
- dim info(4)
- url="http://www.qyqx.cn/zyyh.asp?class=fenxian"
-
- set http=wscript.createobject("Microsoft.XMLHttp")
- '-------连接、处理超时------------
- http.open "GET",url,true
- http.send
- for i=1 to 10
- if http.readystate=4 then '11
- exit for
- end if
- wscript.sleep 500
- next
- '------------5秒都过去了,还不行,去死!---------
- if not http.readystate=4 then
- wscript.echo "连接服务器超时!请稍后连接..."
- exit function
- end if
-
- vIn=http.ResponseBody
- 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
-
- '---------------取得英德段的信息---------------
- pos=instr(strReturn,"英德") '36
- pos1=instr(strReturn,"阳山")
- length=pos1-pos
- getinfo=mid(strReturn,pos-75,length)
- '----------------分割信息----------------------
- for i=0 to 4
- mypos=instr(getinfo,"<")
- mypos1=instr(getinfo,"td>")
- length1=mypos1-mypos
- info(i)=mid(getinfo,mypos,length1)
- info(i)=right(info(i),len(info(i))-74)
- info(i)=left(info(i),len(info(i))-2)
- getinfo=right(getinfo,len(getinfo)-mypos1)
- next
- wscript.echo "城市: "&info(0)&vbcrlf&"白天现象: " & info(1)&vbcrlf&"夜晚现象: " & info(2)&vbcrlf&"最
-
- 低温度: " & info(3)&vbcrlf& "最高温度: " & info(4)
- end function
- connect()
复制代码
|