|
应用XMLHTTP方法导入asp页面静态生成:
程序
'---------------
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("有错误产生!")
else
response.write("<br><font color='#ff0000'>成功生成页面<font>")
'response.write("<meta http-equiv='refresh' content='2;URL=/house/index.htm'>")
end if
End Sub
Call makehtml()
这种方法好不好呢,如果行的话那生成首页也可以这样了,,
大家说说这方法的好与不好,这方法生成速度不快,
我了解到应用一个:
<script>function onDownloadDone(downDate){showImport.innerHTML=downDate}oDownload.startDownload('ASP文件地址',onDownloadDone)</script> 这样单个生成每个页面了,但要怎么实现呢,
|
|