Method 1
<%
'Commonly used functions
'1. Enter the url target web page address, and the return value getHTTPPage is the html code of the target web page.
function getHTTPage(url)
dimHttp
set Http=server.createobject("MSXML2.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
'2. Convert Ranma. Directly use xmlhttp to call web pages with Chinese characters. What you get will be Ranma. You can convert it through the adodb.stream component.
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
txtURL=server.MapPath("../index.asp")
sText = getHTTPPage(txtURL)
Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
filename="../index.htm"
Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) 'true means it does not exist and will be created by itself
openFile.writeline(sText)
Set OpenFile=nothing
%>
<script>
alert("Static web page generation completed");
history.back();
</script>
Method 2:
resourcefile=server.MapPath("../index.asp")
targetfile=server.MapPath("../index.htm")
Set html = Server.CreateObject("CDO.Message")
html.CreateMHTMLBody resourcefile,31
indexcode=html.HTMLBody
Set html = Nothing
if instr(indexcode,"</BODY></HTML>")<=0 then
response.Write("Home page generation failed")
response.End()
else
Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
Set outfile=oFileSys.CreateTextFile(targetfile)
outfile.WriteLine indexcode
outfile.close
Set outfile=nothing
set oFileSys=nothing
response.Write("Home page generated!")
end if