生成静态的HTML页面处理模式

健叶新吉橙 2004-08-06 06:00:51
动态的有连数据库的页面(如ASP),如何生成静态的HTML页面处理模式,来减轻服务器负担。大型的网站都是这样做的,如阿里巴巴

注:讲下处理模式即可
...全文
133 7 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
街头小贩 2004-08-06
  • 打赏
  • 举报
回复
不错!值得提取学习
cdsun 2004-08-06
  • 打赏
  • 举报
回复
是不是哦
不错阿
TSD 2004-08-06
  • 打赏
  • 举报
回复
上面的是我以前做的,调用方法:

dim url,gcode,fname,wr
url="www.xxx.com/xxx.asp"
fname="myfile.htm"
gcode=GetHtmlCode(url)
wr=WriteHtml(gcode,fname)
TSD 2004-08-06
  • 打赏
  • 举报
回复
'获取网页HTML内容
Function GetHtmlCode(url)
dim http
set http=Server.createobject("Microsoft.XMLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
GetHtmlCode=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

'写文件
Function WriteHtml(htmlcode,htmlname)
Dim fpath,fname,fso,fout
fname=htmlname '要生成的文件名
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.Createtextfile(server.mappath(fname),true)
fout.writeline htmlcode '文件内容
fout.close
set fout=nothing
set fso=nothing
WriteHtml="写文件:" & server.mappath(htmlname) & " 成功"
End Function
jnnxwjh 2004-08-06
  • 打赏
  • 举报
回复
在服务器用FSO对象
ghy412 2004-08-06
  • 打赏
  • 举报
回复
关注
TSD 2004-08-06
  • 打赏
  • 举报
回复
获取HTML代码,再写成文件不就得了

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧