asp生成静态HTML(动态读取)
发布时间:2013-06-27 19:54:48
标签:asp,生成静态HTML
<!--#include file="admin_Checkuser.asp"-->
<%
call ConnectionDatabase()
dim str,str_new
str=""
str_new=""
sqlx="select id from Fl_Products order by id desc"
set rsx=conn.execute(sqlx)
do while not rsx.eof
str=str&rsx("id")&"|"
rsx.movenext :loop
rsx.close
sqlx="select id from Fl_News order by id desc"
set rsx=conn.execute(sqlx)
do while not rsx.eof
str_new=str_new&rsx("id")&"|"
rsx.movenext :loop
rsx.close
place=InStrRev(str,"|")
str=Left(str,place-1)
place=InStrRev(str_new,"|")
str_new=Left(str_new,place-1)
dim url,cwww,act
act=Trim(Request.QueryString("act"))
url =Request.ServerVariables("HTTP_HOST")
cwww="http://"+url
MakeHtm cwww&"/index.asp","../index.htm","首页写入成功!"
MakeHtm cwww&"/about.asp","../about.htm","企业简介写入成功!"
MakeHtm cwww&"/contact.asp","../contact.htm","联系我们写入成功!"
MakeHtm cwww&"/ry.asp","../ry.htm","资质荣誉写入成功!"
MakeHtm cwww&"/liuyan.asp","../liuyan.htm","联系我们写入成功!"
MakeHtm cwww&"/pro.asp","../pro.htm","产品展示写入成功!"
MakeHtm cwww&"/news.asp","../news.htm","生成车间写入成功!"
MakeHtm cwww&"/xinwen.asp","../xinwen.htm","新闻资讯写入成功!"
MakeHtm cwww&"/alliance.asp","../alliance.htm","销售网络写入成功!"
'生成产品
xstr=split(str,"|")
for i=0 to ubound(xstr)
MakeHtm cwww&"/uzProduct.asp?id="&xstr(i),"../uzProduct_"&xstr(i)&".htm","产品"&xstr(i)&"写入成功!"
next
xstr=split(str_new,"|")
for i=1 to ubound(xstr)/25+1
MakeHtm cwww&"/xinwen.asp?Page="&i,"../xinwen_"&i&".htm","新闻列表"&i&"写入成功!"
next
xstr=split(str_new,"|")
for i=0 to ubound(xstr)
MakeHtm cwww&"/uzNews.asp?id="&xstr(i),"../uzNews_"&xstr(i)&".htm","新闻"&xstr(i)&"写入成功!"
next
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 MakeHtm(curl,turl,mess)
Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'把下面的地址替换成你的首页的文件地址,一定要用http://开头的绝对路径,不能写相对路径
xml.Open "GET", curl, False
xml.Send
BodyText=xml.ResponseBody
BodyText=BytesToBstr(BodyText,"gb2312")
Set xml = Nothing
'替换
BodyText=RegReplace(BodyText,"uzProduct\.asp\?id=(\d*)", "uzProduct_$1.htm")
BodyText=RegReplace(BodyText,"uzNews\.asp\?id=(\d*)", "uzNews_$1.htm")
BodyText=RegReplace(BodyText,"xinwen\.asp\?Page=(\d*)", "xinwen_$1.htm")
BodyText=replace(BodyText,"index.asp","index.htm")
BodyText=replace(BodyText,"about.asp","about.htm")
BodyText=replace(BodyText,"pro.asp","pro.htm")
BodyText=replace(BodyText,"news.asp","news.htm")
BodyText=replace(BodyText,"liuyan.asp","liuyan.htm")
BodyText=replace(BodyText,"ry.asp","ry.htm")
BodyText=replace(BodyText,"xinwen.asp","xinwen.htm")
BodyText=replace(BodyText,"contact.asp","contact.htm")
Dim fso, MyFile
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile= fso.CreateTextFile(server.MapPath(turl), True)
MyFile.WriteLine(BodyText)
MyFile.Close
response.Write mess
response.Write "<br>"
End Function
Public Function RegReplace(sContent, sPatrn, sNewStr)
Dim oTempReg : Set oTempReg = New RegExp
With oTempReg
.IgnoreCase = True
.Global = True
.Pattern = sPatrn
RegReplace = .Replace(sContent, sNewStr)
End With
Set oTempReg = Nothing
End Function
call CloseDatabase()
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>Untitled Document</title>
<style>
body,td{font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10.5pt;}
</style>
</head>
<body>
</body>
</html>
来自 iisboy
0
投稿
猜你喜欢
- 嵌套模板(Nested Template),其实就是基于另一个模板创建的模板。要创建嵌套模板,首先要保
- 可输入的下拉列表框(select),这个不同于网页上常见的下拉列表框,那个是只能选择不能输入的,而这个是可以自己输入文字的。例如:我们最常见
- 本文实例讲述了php数组索引与键值操作技巧。分享给大家供大家参考。具体如下:<?php $array = array("a&
- 首先这个是7米当时问我一个问题,不过可惜我不知道怎么解决,后来知道解决方法很简单,只是添加了一个margin-top:-1em就
- 上一篇介绍了 HTML5 中 Canvas 的路径,这篇将要介绍一下 Canvas&nbs
- 各大云计算提供商(亚马逊、谷歌和微软)目前都使用了键/值存储方式。然而,在San Francisco召开的MSDN开发者大会上,微软宣布他们
- 网上广泛流传的取 object 的绝对位置的做法是:var getAbsPos = function(pTar
- asp函数代码 代码如下:<% Function RemoveHTML(str) Dim objRegExp, Match,strHT
- 以国内最流行ASP为例,我不知道有多少人会在写代码时想到“容错”这个概念,实际上当我遇到这种事时,也是不了了之。为什么呢,想想最初的意思是认
- PDOStatement::errorInfoPDOStatement::errorInfo — 获取跟上一次语句句柄操作相关的扩展错误信息
- 您可以使用 ObjectContext 对象提交或放弃一项由 Microsoft Transaction Server (MTS) 管理的事
- 在Web上使用菜单可以极大地节约页面的空间,同时也比较的符合用户从Windows上继承下来的UI操作体验。在以往的Web页菜单设计中,我们普
- JS操作二进制很麻烦,而且一直没有一个好的无损压缩工具来实现纯文本的压缩。所以钻研了一段时间的gzip,后来发现还是仅用 LZ77 比较容易
- MySQL的本地备份和双机相互备份脚本:首先,我们需要修改脚本进行必要的配置,然后以root用户执行。◆1. 第一执行远程备份时先用 fir
- 在CSS中我们会经常要用到“清除浮动”Clear,比较典型的就是clear:both;CSS手册上是这样说明的:该属性的值指出了不允许有浮动
- 什么是冗余字段?在设计数据库时,某一字段属于一个表,但它又同时出现在另一个或多个表,且完全等同于它在其本来所属表的意义表示,那么这个字段就是
- <% class menusPublic Title, ID, Image, TitleColor, Target, Backgrou
- 原文:http://www.smashingmagazine.com/ ... emarkable-favicons/翻译:Blank(怿飞
- 以查询前20到30条为例,主键名为id 方法一: 先正查,再反查 select top 10 * from (select top 30 *
- 这几天转了几个内容包含日语的贴,结果发现搜索数据库时出现“内存溢出”错误。上网搜索寻求答案未果。最后才发现这就是传说中的“日文 26 个片假