加入收藏 | 设为首页 | 会员中心 | 我要投稿 南平站长网 (https://www.0599zz.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

asp生成静态HTML(动态读取)

发布时间:2016-12-08 04:17:24 所属栏目:PHP教程 来源:站长网
导读:复制代码 代码如下: lt;!--#include file="admin_Checkuser.asp"--gt; nbsp;lt;% 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 st
复制代码 代码如下:
lt;!--#include file="admin_Checkuser.asp"--gt;
nbsp;lt;%
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=strrsx("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_newrsx("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)
nbsp;dim url,cwww,act
nbsp;act=Trim(Request.QueryString("act"))
url =Request.ServerVariables("HTTP_HOST")
cwww="http://"+url
nbsp;nbsp;nbsp; MakeHtm cwww"/index.asp","../index.htm","首页写入成功!"
nbsp;nbsp;nbsp; 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","生成车间写入成功!"
nbsp;nbsp;nbsp; MakeHtm cwww"/xinwen.asp","../xinwen.htm","新闻资讯写入成功!"
nbsp;nbsp;nbsp; 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
nbsp;Function MakeHtm(curl,turl,mess)
nbsp;Set xml = Server.CreateObject("Microsoft.XMLHTTP")
'把下面的地址替换成你的首页的文件地址,一定要用http://开头的绝对路径,不能写相对路径
xml.Open "GET", curl, False
xml.Send
BodyText=xml.ResponseBody
BodyText=BytesToBstr(BodyText,"gb2312")
Set xml = Nothing
nbsp;'替换
nbsp;BodyText=RegReplace(BodyText,"uzProduct.asp?id=(d*)", "uzProduct_$1.htm")
nbsp;BodyText=RegReplace(BodyText,"uzNews.asp?id=(d*)", "uzNews_$1.htm")
nbsp;BodyText=RegReplace(BodyText,"xinwen.asp?Page=(d*)", "xinwen_$1.htm")
nbsp;BodyText=replace(BodyText,"index.asp","index.htm")
nbsp;BodyText=replace(BodyText,"about.asp","about.htm")
nbsp;BodyText=replace(BodyText,"pro.asp","pro.htm")
nbsp;BodyText=replace(BodyText,"news.asp","news.htm")
nbsp;BodyText=replace(BodyText,"liuyan.asp","liuyan.htm")
nbsp;BodyText=replace(BodyText,"ry.asp","ry.htm")
nbsp;BodyText=replace(BodyText,"xinwen.asp","xinwen.htm")
nbsp;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 "lt;brgt;"
End Function
Public Function RegReplace(sContent, sPatrn, sNewStr)
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; Dim oTempReg : Set oTempReg = New RegExp
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; With oTempReg
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; .IgnoreCase = True
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; .Global = True
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; .Pattern = sPatrn
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; RegReplace = .Replace(sContent, sNewStr)
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; End With
nbsp;nbsp;nbsp;nbsp;nbsp;nbsp;nbsp; Set oTempReg = Nothing
End Function
call CloseDatabase()
nbsp; %gt;
nbsp; lt;htmlgt;
lt;headgt;
lt;meta http-equiv="Content-Type" content="text/html; charset=gb2312" /gt;
lt;titlegt;Untitled Documentlt;/titlegt;
lt;stylegt;
body,td{font-family:Verdana, Arial, Helvetica, sans-serif;
font-size:10.5pt;}
lt;/stylegt;
lt;/headgt;
lt;bodygt;
lt;/bodygt;
lt;/htmlgt;


来自 iisboy

(编辑:南平站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读