当前位置: 首页 > 图文教程 > 网络编程 > ASP > 通过XMLHTTP实现模板式静态页生成

ASP
asp #include命令
推荐下天枫常用ASP函数封装,推荐大家使用
asp最简单最实用的计数器
用asp实现的iframe批量替换工具
ASPWebPack 代码 提供下载
asp分页生成html的程序脚本代码
比较不错的asp单表单字段多条件查询
asp下用replace非正则实现代码运行功能的代码
UpdatePanel触发javascript脚本的方法附代码
生成EAN13标准的条形码的ASP代码实例
asp空间奸商查询系统
ASPWebPack(整站文件备份系统) v1.0.2 黑客也用
ASP+FSO可视化目录编历(可增、删、改)下载
提高ASP效率的五大技巧
ASP生成随机字符串(数字+大小写字母)的代码
ASP下存储过程编写入门全接触
利用 cache 做对比静态页的网页技术
ASP生成静态文件编码为UTF-8格式的HTML文件
ASP下的两个防止SQL注入式攻击的Function
asp下的风讯用的SQL通用防注入模块提供了

ASP 中的 通过XMLHTTP实现模板式静态页生成


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 256 ::
收藏到网摘: n/a

前两天在给自己的一个网站(www.cfsoft.com.cn)做一个文章发布程序,为了使网站更容易被搜索网站收录所以将内容都生成为静态页

一、xxfb表结构如下

type   类型,在我的网站中用来区分几个栏目,我那里有一个技术,一个新闻

pagetitle页面标题

keywords页面关键字

description页面mata里的描述

doctitle 文章标题

doctext文章内容

thedate发布时间

orderid排序代号

commend标注是否为推荐文章

二、每一个类型定义一个list_加类型名的目录模板页面,一个temp_加类型名的文章模板页面

三、以下为静态页生成主体程序

以下为引用的内容:
If Trim(request("flag"))="BUILD" Then
'---生成目录------
sql="select distinct type from xxfb"
Set objrs=conn.execute(sql)
While Not objrs.eof
url = siteurl&"/admin/list_"&Trim(objrs("type"))&".asp"
set http=Server.createobject("Msxml2.XMLHTTP")
Http.open "GET",url,false
Http.send()
set objStream = Server.CreateObject("ADODB.Stream")
objStream.type = 1
objStream.open
objstream.write http.responseBody
objstream.saveToFile server.mappath("/"&Trim(objrs("type"))&"/"&Trim(objrs("type"))&".htm"),2
objstream.close
Set objstream=Nothing
   objrs.movenext
Wend
Set objrs=Nothing

sql="select * from xxfb order by thedate desc"
Set objrs=conn.execute(sql)
While Not objrs.eof
   url = siteurl&"/admin/temp_"&Trim(objrs("type"))&".asp?id="&Trim(objrs("id"))
   set http=Server.createobject("Msxml2.XMLHTTP")
   Http.open "GET",url,false
   Http.send()
   set objStream = Server.CreateObject("ADODB.Stream")
   objStream.type = 1
   objStream.open
   objstream.write http.responseBody
   objstream.saveToFile server.mappath("/"&Trim(objrs("type"))&"/"&Trim(objrs("id"))&".htm"),2
   objstream.close
   Set objstream=Nothing
   objrs.movenext
wend
Response.Write "生成静态网页成功!"
End if