Page | conversion
Some time ago There is an ASP page to perform slowly, the number of visitors, and not often modified, and lazy directly into static, every time to download from the server to change, had to think of ways to convert the ASP page into the HTM static page ...
Have seen such an article before, but did not care too much, really want to use when it is difficult to find a suitable, so the online search for a long time to finally find the more appropriate code plus their own changes, as follows:
<%
Functiongetpage (URL)
' Get the contents of the file
Dimretrieval
Setretrieval=createobject ("Microsoft.XMLHTTP")
Withretrieval
. Open "Get", Url,false ', "", "" "
. Send
Getpage=bytestobstr (. Responsebody)
Endwith
Setretrieval=nothing
Endfunction
Functionbytestobstr (body)
Dimobjstream
Setobjstream=server.createobject ("ADODB.stream")
Objstream. Type=1
Objstream. Mode=3
Objstream. Open
Objstream. Writebody
Objstream. Position=0
Objstream. type=2
Objstream. charset= "GB2312"
Bytestobstr=objstream. ReadText
Objstream. Close
Setobjstream=nothing
Endfunction
Onerrorresumenext
Url= the address of the page to read
Response.Write "Start updating the home page ..."
Wstr=getpage (URL)
' Response.Write (WSTR)
Setfs=server.createobject ("Scripting.FileSystemObject")
' Ifnotmyfile.folderexists (server. MapPath ("/html/")) Then
' Myfile.createfolder (server. MapPath ("/html/")) '
' EndIf
' Address of the page to be stored
Dizhi=server. MapPath ("index.htm")
If (fs. FileExists (Dizhi)) Then
Fs. DeleteFile (Dizhi)
EndIf
Setcrfi=fs. CreateTextFile (Dizhi)
Crfi.writeline (WSTR)
Setcrfi=nothing
Setfs=nothing
Response.Write "...<fontcolor=red> Update complete!" </font> "
%>
Code is the simplest, directly saved into an ASP file can be, as long as the URL (to convert the ASP address) and Dizhi (to save the HTML address) set up on it, generally these two files in the same directory, in order to ensure that the picture or CSS, JS function.
Hope to be useful to those who are looking for asp->htm.