[Title]Convert an ASP page to an HTM page
[Content]
Some time ago, an ASP page was executed very slowly, with a large number of visitors and was not modified frequently. I was too lazy to directly make it static. I had to download and modify it from the server every time, I had to find a way to convert ASP pages into HTM static pages...
I have seen such an article before, but I am not very concerned about it. It is difficult to find a suitable one when I really want to use it, after searching online for half a day, I finally found a suitable code and added my own modifications, as shown below:
<%
Function getpage (URL)
'Get File Content
Dim Retrieval
Set retrieval = Createobject ("Microsoft. XMLHTTP ")
With Retrieval
. Open "get", URL, false ',"",""
. Send
Getpage = bytestobstr (. responsebody)
End
Set retrieval = nothing
End Function
Function bytestobstr (Body)
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 = "gb2312"
Bytestobstr = objstream. readtext
Objstream. Close
Set objstream = nothing
End Function
On Error resume next
Url = "http://www.sina.com.cn" 'the address of the page to read
Response. Write "start to update the homepage ..."
Wstr = getpage (URL)
'Response. Write (wstr)
Set FS = server. Createobject ("scripting. FileSystemObject ")
'If not myfile. folderexists (server. mappath ("/html/") then
'Myfile. createfolder (server. mappath ("/html /"))'
'End if
'Page address to store
Dizhi = server. mappath ("index.htm ")
If (FS. fileexists (dizhi) then
FS. deletefile (dizhi)
End if
Set crfi = FS. createtextfile (dizhi)
Crfi. writeline (wstr)
Set crfi = nothing
Set FS = nothing
Response. Write "... <font color = Red> Update complete! </Font>"
%>
The Code is the simplest and can be directly saved as an ASP file. You only need to set the URL (ASP address to be converted) and dizhi (HTML address to be saved, generally, these two files are in the same directory to ensure that images, CSS, and JS work.
Hope to be useful to those who are looking for HTM generated by ASP.
[Keyword]ASP page to HTML page