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

ASP
ASP编程中15个非常有用的例子 (二)
ASP与JSP的比较(一)
ASP与JSP的比较(二)
ASP中五种连接数据库的方法
从ASP调用SQL中的图像
用排序串字段实现树状结构(例程:连接字串)
用排序串字段实现树状结构(例程:删除贴子)
用排序串字段实现树状结构(例程:回复表单)
用排序串字段实现树状结构(例程:显示贴子内容)
用排序串字段实现树状结构(例程:显示树)
用排序串字段实现树状结构(存储过程)
用排序串字段实现树状结构(库结构)
用排序串字段实现树状结构(原理)
remote script文档(转载自微软)(一)
remote script文档(转载自微软)(二)
remote script文档(转载自微软)(三)
remote script文档(转载自微软)(四)
remote script文档(转载自微软)(五)
remote script文档(转载自微软)(六)
remote script文档(转载自微软)(七)

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 127 ::
收藏到网摘: 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