<!--#include file=function.asp--> <% Dim Url,html,time Time=request ("Time") Url= "Http://weather.cncn.com/get_weather.php?action=get_city&time= '" &time& "'"//Read the weather information on the CNCN Html = Gethttppage (URL) Html=replace (Html, "CNCN", "d58") Response.Write Html %> Let's look at the function.asp file. <% Function gethttppage (httpurl) If IsNull (httpurl) =true Or httpurl= "$False $" Then gethttppage= "$False $" Exit Function End If Dim Http Set http=server.createobject ("Msxml2.xmlhttp") Http.open "Get", Httpurl,false http.send () If Http.readystate<>4 Then Set http=nothing gethttppage= "$False $" Exit function End If gethttppage=bytestobstr ( Http.responsebody, "GB2312") Set http=nothing If err.number<>0 then & nbsp; err.clear 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 Function GetBody (Constr,startstr,overstr,inclul,inclur) If constr= "$False $" or constr= "" or IsNull (constr) =true or startstr= "" or IsNull (STARTSTR) =true or overstr= "" or IsNull (Ov ERSTR) =true Then Getbody= "$False $" Exit Function End If Dim constrtemp Dim Start,over Constrtemp=lcase (CONSTR) Startstr=lcase (STARTSTR) Overstr=lcase (OVERSTR) Start = InStrB (1, Constrtemp, Startstr, Vbbinarycompare) If Start<=0 Then Getbody= "$False $" Exit Function Else If Inclul=false Then Start=start+lenb (STARTSTR) End If End If OVER=INSTRB (Start,constrtemp,overstr,vbbinarycompare) If over<=0 Or Over<=start Then Getbody= "$False $" Exit Function Else If inclur=true Then Over=over+lenb (OVERSTR) End If End If GETBODY=MIDB (Constr,start,over-start) End Function Function Showerr (errmsg) Response.Write <script>alert (' & errmsg & '); History.back (); </ Script> " Response.End End Function %> |