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

时间: 2024-09-20 20:50:22

asp生成静态HTML(动态读取)的相关文章

asp生成静态HTML(动态读取)_应用技巧

复制代码 代码如下: <!--#include file="admin_Checkuser.asp"--> <% call ConnectionDatabase()dim str,str_newstr=""str_new=""sqlx="select id from Fl_Products order by id desc" set rsx=conn.execute(sqlx)do while not rsx

ASP.Net/asp 生成静态HTML页

asp.net|静态 环境:Microsoft .NET Framework SDK v1.1 OS:Windows Server 2003 中文版 ASP.Net生成静态HTML页 在Asp中实现的生成静态页用到的FileSystemObject对象! 在.Net中涉及此类操作的是System.IO 以下是程序代码 注:此代码非原创!参考别人代码 //生成HTML页   public static bool WriteFile(string strText,string strContent,

最简单的ASP生成静态HTML页的方法[FSO支持]

下面介绍给大家一个最简单的ASP生成静态HTML页的方法,不用模板也能快速生成.比如要生成一个正常的index.asp页面,并且用ASP代码调出数据库中的内容,另建一个makehtml.asp的页面,加入一个textarea域,假设为name="body",将index.asp在textarea里调出来,如:<textarea name="body"><!--#include file="index.asp"--><

asp生成静态页主要涉及三个方面:模板,参数,fso

fso|静态|模板 asp生成静态页主要涉及三个方面:模板,参数,fso. 1,模板:这个其实就是页面的框架,以下为模板的例子:###############################这就是一个模板###############################<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-t

ASP生成静态htm页面基本代码!

ASP生成静态htm页面基本代码! 以下虚线框内为mk.asp文件的具体代码: -------------------------------------------------------------------------------- <% filename="test.htm" if request("body")<>"" then set fso = Server.CreateObject("Scriptin

ASP生成静态首页的示例代码

简单点的,ASP生成静态首页的示例代码 <% dim objXmlHttp,binFileData,objAdoStream set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP") objXmlHttp.open "GET","http://"&request.ServerVariables("HTTP_HOST")&"/index1.

比较ASP生成静态HTML文件的几种方法

将动态页面转换生成静态Html文件有许多好处,比如生成html网页有利于被搜索引擎收录(特别是对接受动态参数的页面).前台访问时,脱离了数据访问,减轻对数据库访问的压力,加快网页打开速度. 当然,凡事有利必有弊,生成HTML页面无形中也耗费大量的磁盘空间以存放这些静态文件,在编辑页面过程中除读写数据库外,也要读写服务器磁盘,页面样式的改动必须重新生成全部HTML文件,等等. 像很多搜索引擎,都可以提交网站的页面地址列表,动态文件的收录问题已经不算是个问题了(如google sitemap).得失

ASP生成静态网页的方法

静态|网页|静态 随着网站访问量的加大,每次从数据库读取都是以效率作为代价的,很多用ACCESS作数据库的更会深有体会,静态页加在搜索时,也会被优先考虑.互联网上流行的做法是将数据源代码写入数据库再从数据库读取生成静态面,这样无形间就加大了数据库.将现有的ASP页直接生成静态页,将会节省很多. 下面的例子是将.index.asp?id=1/index.asp?id=2/index.asp?id=3/这三个动态页面,分别生成ndex1.htm,index2.htm,index3.htm存在根目录下

ASP生成静态HTML文件的几种方法比较

比较|静态 将动态页面转换生成静态Html文件有许多好处,比如生成html网页有利于被搜索引擎收录(特别是对接受动态参数的页面).前台访问时,脱离了数据访问,减轻对数据库访问的压力,加快网页打开速度. 当然,凡事有利必有弊,生成HTML页面无形中也耗费大量的磁盘空间以存放这些静态文件,在编辑页面过程中除读写数据库外,也要读写服务器磁盘,页面样式的改动必须重新生成全部HTML文件,等等. 像很多搜索引擎,都可以提交网站的页面地址列表,动态文件的收录问题已经不算是个问题了(如google sitem