asp生成靜態(tài)HTML(動態(tài)讀取)
更新時間:2013年08月22日 23:06:51 作者:
這樣的代碼多用于我們沒有實現(xiàn)設(shè)計生成靜態(tài)的功能,但又想臨時將一些動態(tài)頁面生成靜態(tài)的,直接獲取動態(tài)內(nèi)容并保存為靜態(tài)的
復(fù)制代碼 代碼如下:
<!--#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","企業(yè)簡介寫入成功!"
MakeHtm cwww&"/contact.asp","../contact.htm","聯(lián)系我們寫入成功!"
MakeHtm cwww&"/ry.asp","../ry.htm","資質(zhì)榮譽寫入成功!"
MakeHtm cwww&"/liuyan.asp","../liuyan.htm","聯(lián)系我們寫入成功!"
MakeHtm cwww&"/pro.asp","../pro.htm","產(chǎn)品展示寫入成功!"
MakeHtm cwww&"/news.asp","../news.htm","生成車間寫入成功!"
MakeHtm cwww&"/xinwen.asp","../xinwen.htm","新聞資訊寫入成功!"
MakeHtm cwww&"/alliance.asp","../alliance.htm","銷售網(wǎng)絡(luò)寫入成功!"
'生成產(chǎn)品
xstr=split(str,"|")
for i=0 to ubound(xstr)
MakeHtm cwww&"/uzProduct.asp?id="&xstr(i),"../uzProduct_"&xstr(i)&".htm","產(chǎn)品"&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
您可能感興趣的文章:
- asp添加數(shù)據(jù)實現(xiàn)代碼
- ASP.NET動態(tài)生成靜態(tài)頁面的實例代碼
- Asp.net動態(tài)生成html頁面的方法分享
- 一個ASP創(chuàng)建動態(tài)對象的工廠類(類似PHP的stdClass)
- asp.net后臺動態(tài)添加JS文件和css文件的引用實現(xiàn)方法
- asp.net后臺如何動態(tài)添加JS文件和css文件的引用
- asp.net通過動態(tài)加載不同CSS實現(xiàn)多界面
- asp.net在后端動態(tài)添加樣式表調(diào)用的方法
- asp.net動態(tài)添加js文件調(diào)用到網(wǎng)頁的方法
- asp.net為網(wǎng)頁動態(tài)添加關(guān)鍵詞的方法
- asp.net動態(tài)加載自定義控件的方法
- ASP.NET創(chuàng)建動態(tài)縮略圖的方法
- asp+jsp+JavaScript動態(tài)實現(xiàn)添加數(shù)據(jù)行
相關(guān)文章
ScriptHtml 函數(shù)之過濾html標(biāo)記的asp代碼
ScriptHtml 函數(shù)之過濾html標(biāo)記的asp代碼...2007-09-09
ASP 循環(huán)導(dǎo)入導(dǎo)出數(shù)據(jù)處理 不使用緩存
非常不錯,大家可以自己應(yīng)用下。2009-01-01
可以應(yīng)用到馬克斯電影站生成Rss Feed的代碼
前段時間為了給本人的電影站增加Rss訂閱功能,動手寫了個動態(tài)生成Rss Feed的ASP代碼,沒法上傳附件,就直接貼代碼吧,反正也不長,用馬克斯做電影站的朋友直接拿去用吧,其它類型的站點修改一下也能用。生成的Rss Feed采用UTF-8編碼,經(jīng)過feedvalidator.org校驗,兼容Rss 2.0和Atom。2008-03-03
ASP是使用正則提取內(nèi)容里所有圖片路徑SRC的實現(xiàn)代碼
有時候客戶提交的內(nèi)容里包含多個圖片,客戶想單獨把圖片路徑提取出來進行保存,下面腳本之家小編跟大家分享ASP正則提取內(nèi)容里所有圖片路徑SRC的方法函數(shù),需要的朋友可以參考下2019-09-09
ASP中使用Set ors=oConn.Execute()時獲取記錄數(shù)的方法
在ASP中,如果你使用Set ors=oConn.Execute()來創(chuàng)建RecordSet對象,再使用RecordSet.RecordCount獲取記錄數(shù)時,你會發(fā)現(xiàn)它的值為-1,這時,我們可以使用GetRows方法來獲取記錄數(shù)。2010-12-12

