站点公告:

如果你要转载本博客内容,请为我加一个链接,谢谢!
欢迎访问http://www.chinazc.net
欢迎大家与我交换友情连接,友情连接请留言

用asp生成静态页面的方法
深度消失 发表于 - 2007-10-1 21:53:00

当你想把a.asp?id=n这样的多个动态页面转换成静态页面,下面的方法就可以帮你实现!

<!--#i nclude virtual="conn.asp"-->/建立数据库连接
<%
pagestart=cint(request.querystring("a"))
pageend=cint(request.querystring("b"))
ssql="select * from database where id>="&pagestart&" and id<="&pageend&""
rst.open ssql,conn,1

GetPage(url)
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.Open "Get", url, False ', "", ""
.Send
GetPage = BytesToBstr(.ResponseBody)
End With
Set Retrieval = Nothing
End

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
do while not rst.eof
i=rst("id")
Url="http://www.***com/***.asp?id="&i&"" '网站数据
wstr = GetPage(Url)
Set fs=Server.CreateObject("ing.FileSystemObject")
Set yzy=fs.CreateTextFile(server.MapPath("view/view"&i&".html"))
yzy.Writeline(wstr)
rst.movenext
loop
rst.close
  set yzy=nothing
  set fs=nothing
response.Write(i)
%>

发表评论:
关 闭
关 闭
博客托管于 梦想博客 Copyright 2006-2008. All rights reserved.