Copy Code code as follows:
<%
' Determine if you want to generate a new HTML
If Application ("cache_asptohtml_date") = "" Then
Application.Lock
Application ("Cache_asptohtml_date") =now ()
Application.UnLock
Call asptohtml
Response.Redirect ("index.html")
End If
If DateDiff ("s", Application ("Cache_asptohtml_date"), now > Then ' compares how many seconds the last update time differs from the current time
Application.Lock
Application ("Cache_asptohtml_date") =now ()
Application.UnLock
Call asptohtml
Response.Redirect ("index.html")
Else
Response.Redirect ("index.html")
End If
' Get the current directory!
function GetPath
If Request.ServerVariables ("Server_port") <> "then"
Userurl = "http://" &request.servervariables ("SERVER_NAME") & ":" & Request.ServerVariables ("SERVER_PORT" ) & Request.ServerVariables ("URL")
Else
Userurl = "http://" &request.servervariables ("SERVER_NAME") & Request.ServerVariables ("URL")
End If
Getpath=left (Userurl,instrrev (Userurl, "/"))
End Function
Sub asptohtml
'----------------------------------------------------------
' Use XMLHTTP to generate static home code
' Curl for your home address, make sure your space support FSO
'-----------------------------------------------------------
Dim read,curl,content
curl=getpath& "Home.asp"
Read=gethttppage (Curl)
If read<> "" Then
Content=read
Set Fso = Server.CreateObject ("Scripting.FileSystemObject")
Filen=server.mappath ("index.html")
Set Site_config=fso. CreateTextFile (Filen,true, False)
Site_config.write Content
Site_config.close
Set Fso = Nothing
End If
End Sub
Function gethttppage (URL)
Dim http
Set Http=server.createobject ("Microsoft.XMLHTTP")
Http.open "Get", Url,false
Http.send ()
If Http.readystate<>4 Then
Exit function
End If
Gethttppage=bytestobstr (Http.responsebody, "GB2312")
Set http=nothing
If Err.number<>0 then err. Clear
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
%>
ASP generated static page (HTML) 2
Copy Code code as follows:
<%
Set Fs=server.createobject ("Scripting.FileSystemObject")
File=server.mappath ("Time.txt")
Set Txt=fs.opentextfile (file,1,true)
If not Txt.atendofstream then
Times=txt. ReadLine
Else
Response.Write "<br/><!--have not found Time.txt started to generate!-->"
HtmlPage = "Time.txt"//generated HTML filename
Template = Now ()
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
Set fileout = FSO. CreateTextFile (Server.MapPath (HtmlPage))
Fileout.writeline Template
Fileout.close
Set FSO = Nothing
End If
If DateDiff ("s", Times,now ()) > 3600 Then '//Last updated to now longer than 3,600 seconds update
Response.Write "<br/><!--time has passed and started to update-->"
Code = "Here is the HTML code that needs to be generated" '//How to get codes there are a lot of ways
'//Use FSO to generate HTML page
HtmlPage = "index.html"//generated HTML filename
Template = code
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
Set fileout = FSO. CreateTextFile (Server.MapPath (HtmlPage))
Fileout.writeline Template
Fileout.close
Set FSO = Nothing
'//Use FSO to generate Time.txt files
HtmlPage = "Time.txt"//generated HTML filename
Template = Now ()
Set FSO = Server.CreateObject ("Scripting.FileSystemObject")
Set fileout = FSO. CreateTextFile (Server.MapPath (HtmlPage))
Fileout.writeline Template
Fileout.close
Set FSO = Nothing
Else
Response.Write "<br/><!--has passed" &datediff ("s", Times,now ()) & "SEC!-->"
End If
%>