大家都知道HTML靜態網頁更容易被搜索引擎收錄索引,動態生成HTML網頁,也可使網站的網頁數量增多,搜索引擎收錄的數量也可能多,再加下提高網頁的質量也意未著什么呢?我想大家也知道。
為了這個,我決定了改變之前網站建設,網頁設計的方法,經過多翻的研究及思考,對多種網頁動態生成的方法,我比較喜歡用標簽替換的方法成生網頁網絡推廣。
標簽替換法:這是我個人理解的定義,不知道別人怎么叫它的,呵呵!
標簽替換法,就是在設計好了的網頁模板中,放入自已設定的標簽,然后用你需要顯示出來的東東替換它。如
模板文件1
這個模板我們保存在數據庫表中 temptable
<html>
<head>
<title>{$SiteName} </title>
</head>
<body>
{$Arc_List$}
</body>
<html>
在以上模板中我放入了兩個標簽{$SiteName}網站名稱和{$Arc_List$}文章列表,再來看下面的代碼
<%
dim rs,SiteName,Arc_List,fso,myFile,FilePath,html
SiteName="我的第一個動態生成的HTML網頁"
FilePath = Server.MapPath("/html/index.html")
set rs=server.createobject("adodb.recordset")
rs.open"select [temp] from temptable,conn,1,1
html = rs("temp") ''''''''讀取網頁模板
rs.close
html = replace(html, "{$SiteName}" , SiteName) ''''''''用自定義的 SiteName 替換{$SiteName}標簽
html = html & replace(html, "{$Arc_List$} " , get_ArcList()) ''''''''用自定義的get_ArcList()函數替換{$Arc_List$}標簽
set rs=nothing
conn.close
set conn=nothing
set fso=CreateObject("***ing.FileSystemObject") ''''''''創建文件系統對象
Set MyFile = fso.CreateTextFile(FilePath,True) ''''''''創建文件
MyFile.WriteLine(html) ''''''''把htm代碼寫入文件
MyFile.close ''''''''關閉文件
Set MyFile = nothing ''''''''釋放文件對象
set fso = nothing ''''''''釋放系統文件對象
response.write "<*** language=''''''''java***''''''''>window.alert(''''''''文件生成成功了'''''''');</***>"
response.end()
Function get_ArcList()
dim str,str1
str1=""
str = "<ul>{list}</ul>"
rs.open"select Title,url from Arc"
while not rs.eof
str1 = str1 & "<li><a href="&rs("url")&">"&rs("Title")&"</a></li>"網站推廣
rs.movenext
wend
rs.close
str = replace(str, "{list}", Str1)
get_ArcList = str
%>
End Function