鐢ˋSP+XMLHTTP缂栧啓涓涓ぉ姘旈鎶ョ▼搴
鍙戝竷: 2008-6-27 11:51 | 浣滆: admin | 鏌ョ湅: 15娆
銆銆鏈汉灏辫亴浜庝竴涓湰鍦伴棬鎴风綉绔欙紝姣忓ぉ缃戠珯涓婄殑澶╂皵閮藉緱鏇存柊銆備箙鑰屼箙涔嬫劅鍒扮浉褰撻夯鐑︼紝浜庢槸鍐欎簡涓涓畾鏃剁殑鏂伴椈灏忓伔锛屽笘鍑烘潵澶у鍙傝冧竴涓嬬郴缁熻姹: 鏀寔FSO, 鏈嶅姟鍣║DP銆TCP/IP 娌℃湁灞忚斀銆
銆銆涓嬮潰鏄皬鍋风殑鍐呭锛
FileName TianQi.ASP
Write By Niaoked QQ408611119
www.knowsky.com
锛%
銆if hour(now)=9 and minute(now)锛30 then
銆銆getCategories()
銆end if
銆Function getCategories()
銆銆on error resume next
銆銆Dim oXMLHTTP ' As Object
銆銆Dim oCategories ' As Object
銆銆Dim BodyText
銆銆Dim Pos,Pos1
銆銆Set oXMLHTTP = CreateObject("Microsoft.XMLHTTP")
銆銆'--- set the XMLHTTP call and issue send (no parm as category
銆銆'--- is included in URL
銆銆oXMLHTTP.open "GET","http://weather.china.com.cn/travel_gntq.PHP?cityid=56196&cityname=缁甸槼",False '杩欎釜鍦版柟鎹㈡垚浣犺嚜宸辩殑鍦板潃
銆銆oXMLHTTP.send
銆銆'--- load the response into the Categories data island
銆銆BodyText=oXMLHTTP.responsebody
銆銆BodyText=BytesToBstr(BodyText,"gb2312")
銆銆Pos=Instr(BodyText,"锛渂ody")
銆銆pos1=Instr(BodyText,"锛/body锛")
銆銆BodyText=mid(BodyText,pos,pos1)
銆銆BodyText=split(BodyText,"锛渢able")
銆銆Pos=Instr(BodyText(4),"锛渢r")
銆銆pos1=Instr(BodyText(4),"锛/tr锛")
銆銆Body=mid(BodyText(4),pos,len(BodyText(4))-pos)
銆銆body=split(body,"锛/table锛")
銆銆body1=split(replace(replace(replace(body(0),"锛渂r锛",""),"锛/td锛",""),"锛/tr锛",""),"澶╂皵")
銆銆for i= 1 to ubound(body1)
銆銆銆body3=split(body1(i),"锛渢d")
銆銆銆weather=weather & "document.write("""& i&"$" & "澶╂皵" & HTMLEncode(trim(body3(0))) & """);" & VBcrlf
銆銆next
銆銆weather=replace(weather,"1$","锛淔ONT color=#ffffff锛炪愪粖澶┿戯紲/FONT锛")
銆銆weather=replace(weather,"2$","锛淔ONT color=#ffffff锛炪愭槑澶┿戯紲/FONT锛")
銆銆weather=replace(weather,"3$","锛淔ONT color=#ffffff锛炪愬悗澶┿戯紲/FONT锛")
銆銆Set fs = CreateObject("Scripting.FileSystemObject")
銆銆Set f = fs.CreateTextFile(request.ServerVariables("APPL_PHYSICAL_PATH")& "tq.js", True)
銆銆f.write("document.write('缁甸槼澶╂皵棰勬姤:');" &vbcrlf & replace(weather,"锛淏R锛",""))
銆銆f.close
銆銆Set f = nothing
銆銆Set fs = nothing
銆銆response.write "缁甸槼澶╂皵棰勬姤:"& weather
銆銆Set oXMLHTTP = Nothing
銆銆if err.number锛滐紴0 then
銆銆銆response.write "鍑洪敊浜嗭紝閿欒鎻忚堪锛"&err.description & "锛渂r锛為敊璇潵婧"& err.source
銆銆銆response.End()
銆銆end if
銆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
銆Public Function HTMLEncode(fString)
銆銆If Not IsNull(fString) Then
銆銆銆fString = replace(fString, "锛", ">")
銆銆銆fString = replace(fString, "锛", "<")
銆銆銆fString = Replace(fString, CHR(32), " ") '
銆銆銆fString = Replace(fString, CHR(9), " ") '
銆銆銆fString = Replace(fString, CHR(34), """)
銆銆銆fString = Replace(fString, CHR(39), "'") '鍗曞紩鍙疯繃婊
銆銆銆fString = Replace(fString, CHR(13), "")
銆銆銆fString = Replace(fString, CHR(10) & CHR(10), "锛/P锛烇紲P锛 ")
銆銆銆fString = Replace(fString, CHR(10), "锛淏R锛 ")
銆銆銆HTMLEncode = fString
銆銆End If
銆End Function
%锛




发表于 2009-1-5 19:48
| 











