This is a method I wrote when I was a beginner at asp to generate static pages,
<% Dim fs
'Timeout '---------------------------------------------------------------------------------------------
Function getHTTPPage (url)
Dim objXML
Set objXML = server. createobject ("MSXML2.XMLHTTP") 'definition
ObjXML. open "GET", url, false' open
ObjXML. send () 'send
If objXML. readystate <> 4 then' is used to determine whether the document has been parsed to receive the returned message from the client.
Exit function
End If
GetHTTPPage = BytesToBstr (objXML. responseBody) 'returns information and uses function-defined encoding.
Set objXML = nothing 'disabled
If err. number <> 0 then err. Clear
End Function
'Timeout '----------------------------------------------------------------------------------------------
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"
'Convert the original default UTF-8 encoding to GB2312 encoding, otherwise the web page with Chinese characters will be garbled directly by calling XMLHTTP
BytesToBstr = objstream. ReadText
Objstream. Close
Set objstream = nothing
End Function
'Timeout '----------------------------------------------------------------------------------------------------
Function savafile (html, htmlfilename)
Chtml = html
Htmlfilename = server. MapPath (htmlfilename)
Call fso ()
Set writerfile = fs. createtextfile (htmlfilename, true)
Writerfile. writeline chtml
Writerfile. close
Chtml = ""
End function
'Timeout '-----------------------------------------------------------------------------------------------------
Function fso ()
Set fs = server. CreateObject ("scripting. filesystemobject ")
End function
'Timeout '------------------------------------------------------------------------------------------------------
Function htmlname (url)
Filename = mid (url, limit Rev (url, "/") + 1)
Newlen = len (filename)-len (mid (filename, limit Rev (filename, ".") + 1 ))
Htmlname = mid (filename, 1, newlen) & "html"
End function
'Timeout '-----------------------------------------------------------------------------------------------------
Function replaceall (html)
Dim temp
Temp = replace (html, "index. asp", "index.html ")
Temp = replace (temp, "music. asp", "music.html ")
Temp = replace (temp, "stuzp. asp", "stuzp.html ")
Temp = replace (temp, "class. asp", "class.html ")
Temp = replace (temp, "tch. asp", "tch.html ")
Temp = replace (temp, "photo. asp", "photo.html ")
Replaceall = replace (temp, "guestbook. asp", "guestbook.html ")
End function
'---------------------------------------------------------------------
Function getphoto (strHTML, key)
Dim objRegExp, Match, Matches
Set objRegExp = New Regexp
ObjRegExp. IgnoreCase = True
ObjRegExp. Global = True
ObjRegExp. Pattern = key
'
Tp = ""
Set Matches = objRegExp. Execute (strHTML)
For Each Match in Matches
Tp = tp & Match. value
Exit
Next
Getphoto = tp
Set objRegExp = Nothing
End Function
'---------------------------------------------------------
Function pagehtml (html)
Bb = getphoto (html, "<! -- Jimmy. +? --> ")
If bb <> "" then
Bb = mid (bb, 10)
Clen = len (bb)-3
Bb = mid (bb, 1, clen)
Pagehtml = bb
End if
End function
'-------------------------------------------------------------------------
Function syname (url)
Filename = mid (url, limit Rev (url, "/") + 1)
Newlen = len (filename)-len (mid (filename, limit Rev (filename ,".")))
Syname = mid (filename, 1, newlen)
End function
Dim arr (6)
Arr (0) = "http://www.111cn.net/stu/index.asp"
Arr (1) = "http://www.111cn.net/stu/music.asp"
Arr (2) = "http://www.111cn.net/stu/stuzp.asp"
Arr (3) = "http://www.111cn.net/stu/class.asp"
Arr (4) = "http://www.111cn.net/stu/tch.asp"
Arr (5) = "http://www.111cn.net/stu/photo.asp"
Arr (6) = "http://www.111cn.net/stu/guestbook.asp"
For I = 0 to 6
Url = arr (I)
Url = arr (I)
TopHtml = getHTTPPage (Url)
Tophtml = replaceall (html)
Topnames = htmlname (url)
S = pagehtml (html)
If s> 1 then
For j = 1 to s
Fyhtml = gethttppage (url &"? Page = "& j)
Names = syname (url)
An = htmlname (url)
Fyhtml = replaceall (fyhtml)
Bs0 = names & j & ". html"
For q = 1 to s
Htm = &"? Page = "& q
Bs = names & q & ". html"
Fyhtml = replace (fyhtml, htm, bs)
Next
Call savafile (fyhtml, bs0)
Next
End if
Call savafile (tophtml, topnames)
Chtml = ""
If error = 0 then
Response. Write ("successfully generated" & topnames)
Else
Response. Write ("generate" & topnames & "failed ")
End if
Response. flush
Response. write ("<br> ")
Next
%>
Original site: For reprint, please indicate www.111cn.net