Getfile.asp
<%
"Use the XMLHTTP component to get the remote file and save it to the current space
"This is an example of Web site building, remote access to a Web page content and filter out the relevant weather data, of course, you can skip the file local storage and then get the data
"Reference to the Xoyu function, thanks here
Fileurl= "Http://www.hbqx.gov.cn/other/tqyb/inc_city_hb.asp"
Dotloc=instrrev (FileURL, ".")
Filepath= "Thistest" &mid (fileurl,dotloc) ' establishes the same type of file name
"Filepath=" thistest.htm "
Call Saveremotefile (Filepath,fileurl)
Sub Saveremotefile (Localfilename,remotefileurl)
Dim ads,retrieval,getremotedata
Set retrieval = Server.CreateObject ("Microsoft.XMLHTTP")
With retrieval
. Open "Get", Remotefileurl, False, "", ""
. Send
Getremotedata =. Responsebody
"Getdetail =. ResponseText ' can get content directly from text files, but can't support Chinese, don't know how to solve
End With
Set retrieval = Nothing
"RESPONSE." WRITE Getdetail
Set Ads = Server.CreateObject ("ADODB.stream") ' generates the corresponding file
With Ads
. Type = 1
. Open
. Write Getremotedata
. SaveToFile server. MapPath (LocalFilename), 2
. Cancel ()
. Close ()
End With
Set ads=nothing
End Sub
"The above completes the Remote Storage file, the following applies only to text-type file operations www.knowsky.com
Set Fso=server.createobject ("Scripting.FileSystemObject") reads the contents of the file
Set Fileout=fso.opentextfile (Server.MapPath (filepath), 1)
Content=fileout.readall
Set fileout=nothing
Set fso=nothing
"' Response.Write content
Contentarr=split (Content, "<td") ' Filtered by contents
For I=1 to UBound (Contentarr)
If InStr (Contentarr (i), "Enshi") then Thisloc=i
Next
Dim Xu (5)
For J=0 to 4
Con1=contentarr (THISLOC+J)
Start1=instr (Con1, ">")
Con1=right (Con1,len (con1)-start1)
Stop1=instr (Con1, "<")
Con1=left (Con1,stop1-1)
Str=str&contentarr (THISLOC+J)
Xu (j) =trim (Con1)
Next
If Xu (1) <> "" Then
Response.Write "document.write (' Enshi next 24 hours weather forecast:" &xu (1) & ", lowest temperature" &xu (2) & "Celsius, maximum temperature" &xu (3) & " degree Celsius, wind Direction: "&xu (4) &".--Wuhan Central Meteorological Observatory issued ');
Else
Response.Write "document.write (' unpublished ');"
End If
' Response.Write Server.HTMLEncode (str)
%>
Referencing the display fetch content in another HTM page
<script src= "getfile.asp" ></script>