|
Apply the XMLHTTP method to import asp pages to generate statically:
program
'---------------
function getHTTPPage (url)
dim Http
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
'----------------
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
'---------------------
Sub makehtml ()
Dim rsa
Dim Url, Html
dim filename, fso, fout
Set fso = Server.CreateObject ("Scripting.FileSystemObject")
Set rsa = server.CreateObject ("adodb.recordset")
rsa.open "select house_class_id from house_class", conn, 3,2
do while Not rsa.eof
Url = "http: //"&request.ServerVariables ("Server_NAME")&"/house/house.asp?id="&rsa("house_class_id") "
Html = getHTTPPage (Url)
filename = "list"&rsa ("house_class_id")&-1&".htm"
Set fout = fso.CreateTextFile (server.mappath (""&filename&""))
fout.Write html
rsa.movenext
loop
rsa.close
fout.close
set fout = nothing
set fso = nothing
if err then
err.Clear
response.Write ("An error occurred!")
else
response.write ("<br> <font color = '# ff0000'> Page <font> successfully generated")
'response.write ("<meta http-equiv =' refresh 'content =' 2; URL = / house / index.htm '>")
end if
End Sub
Call makehtml ()
Is this method good? If you can, then you can also generate the homepage,
Everyone talk about the good or bad of this method.This method is not fast.
I learned to apply one:
<script> function onDownloadDone (downDate) {showImport.innerHTML = downDate} oDownload.startDownload ('ASP file address', onDownloadDone) </ script> This generates each page individually, but how to implement it |
|