下面这段是它的源文件
2007年1月16日 星期二 下午17:02 多云转阵雨 25℃~34℃ | |
http://www.yuexiu.gov.cn/index/weather_index.jsp
看这页,它是通过后台一个动态文件,读取http://weather.news.163.com
上的天气数据,然后过滤掉他不许要的数据,从新显示天气出来.
参考:http://news.163.com/weather/
------------
<%
'-----测试函数-----
dim tx
set tx = new grkz_weather
tx.get_265weather
set tx = nothing
'----测试类------
'-----测试时间:2007-6-18----
class grkz_weather
'asp环境下采集类,需要服务器支持XMLHTTP
public function get_265weather()
'针对 weather.265.com 的采集程序
dim wstr,start,over,tmp
wstr=getHTTPPage("http://weather.265.com/get_weather.php?action=get_city&time=2")
start=Newstring(wstr,"href=")
over=Newstring(wstr,"?time=2")
wstr=mid(wstr,start+6,over-start)
tmp = getHTTPPage("http://weather.265.com/"&wstr)
tmp = replace(tmp,"../js/weather_265_1.js","http://weather.265.com/js/weather_265_1.js")
response.Write tmp
end function
function gethttppage(path)
dim tmp
tmp = getbody(path)
gethttppage=bytestobstr(tmp,"GB2312")
end function
function getbody(url)
dim retrieval
on error resume next
set retrieval = createobject("Microsoft.XMLHTTP")
with retrieval
.open "Get", url, false, "", ""
.send
getbody = .responsebody
end with
set retrieval = nothing
end function
function bytestobstr(body,cset)
dim objstream
set objstream = server.createobject("adodb."&"stream")
objstream.type = 1
objstream.mode =3
objstream.open
objstream.write body
objstream.position = 0
objstream.type = 2
objstream.charset = cset
bytestobstr = objstream.readtext
objstream.close
set objstream = nothing
end function
function newstring(wstr,strng)
newstring=Instr(lcase(wstr),lcase(strng))
if newstring<=0 then newstring=Len(wstr)
end function
end class
%>