|
Set xmlh = CreateObject("msxml2.xmlhttp") ‘需要聲明的對(duì)象
Function Weather()
xmlh.open "GET","http://www.baidu.com/s?wd=%CC%EC%C6%F8&f=12&rsp=0&oq=tianqi&tn=baiduhome_pg",False
xmlh.send
html = xmlh.responseText
str_temp = "</a></div><strong altemp_special" & Chr(34) & ">"
a = InStr(html,str_temp) + Len(str_temp)
b = InStr(a,html,"</strong><br><strong>")
c = b + Len("</strong><br><strong>")
d = InStr(c,html,"</strong><br><span>")
Today_Temp = Mid(html,a,b - a)
Today_Weather = Mid(html,c,d - c)
Today_Wind = Mid(html,d + Len("</strong><br><span>"),InStr(d,html,"</span></td>") - (d + Len("</strong><br><span>")))
a = InStr(d,html,"</a></div>") + Len("</a></div>")
b = InStr(a,html,"<br>")
c = InStr(b + 4,html,"<br><span>")
Tomorrow_Weather = Mid(html,b + 4,c - b - 4)
Tomorrow_Temp = Mid(html,a,b - a)
Tomorrow_Wind = Mid(html,c + Len("<br><span>"),InStr(c,html,"</span></td>") - (c + Len("<br><span>")))
a = InStr(c,html,"</a></div>") + Len("</a></div>")
b = InStr(a,html,"<br>")
c = InStr(b + 4,html,"<br><span>")
the_weather = Mid(html,b + 4,c - b - 4)
the_Temp = Mid(html,a,b - a)
The_Wind = Mid(html,c + Len("<br><span>"),InStr(c,html,"</span></td>") - (c + Len("<br><span>")))
Line1 = "近日天氣預(yù)報(bào)"
Line2 = "今日" & today_temp & "," & today_weather & "," & today_wind
Line3 = "明日" & tomorrow_temp & "," & tomorrow_weather & "," & tomorrow_wind
Line4 = "后天" & the_temp & "," & the_weather & "," & the_wind
Weather = line1 & vbCrLf & line2 & vbCrLf & line3 & vbCrLf & line4
End Function
Msgbox Weather()
’返回值就是天氣預(yù)報(bào)
|
|