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

相关内容推荐

获得当前页面地址和来路地址

当前页面地址: html="http://" html=htmlRequest.ServerVariables("Server_Name") html=htmlRequest.ServerVariables("URL") ifrequest.ServerVariables("QUERY_STRING")""then html=html"?"Request.ServerVariables("QUERY_STRING") endif session("

怎样用ASP压缩文件

多数的时候我们需要压缩文件,保存到特定的位置,或者你可以使用它实现所有你想要的效果。 我们需要服务器支持WScript.Shell-多数的站长都不会允许这样的。 这里你可以获取下载链接

用ASP生成Excel文件

用asp生成Excel文件不是像我认为的那么容易。我想这小段代码应该能帮助大家找到输出数据到csv和xls的方法。 %@LANGUAGE="VBSCRIPT" CODEPAGE="936"%meta http-equiv="Content-Type" content="text/html; charset=

实现多条件模糊查询SQL语句

很多网友问到如何写模糊查询语句和多条件查询,这里我整理了一下,假设以姓名、性别、电话号...作为数据库中的字段名。 通常写一个简单的模糊查询的SQL语句格式可以如下例: sq

html中用js调用ASP文件,实现静态页面动态显示

html中用js调用ASP文件,实现静态页面动态显示,比如HMTL文章的动态新闻评论等 ---简单版[调用代码,把他放哪儿,就在哪儿显示]-------- script language="javascript" src="asdf.asp"/script-----asdf.asp文

返回
顶部