ASP Weather Query system code

Source: Internet
Author: User
The code is as follows Copy Code

<!--#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
%>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.