asp簡單產生靜態的方法,今天看了字典工具裡面的程式碼,比較簡單,需要的朋友可以參考下。 CreateHtml
所有文章生成,好用資源大
第一種方法:
複製代碼代碼如下:
'開始HTML產生方式
Set Rs=Server.Createobject(Adodb.Recordset)
Sql=Select KQIQI_ID,KQIQI_Title,KQIQI_Pinyin,KQIQI_Explain,KQIQI_Content,KQIQI_Record From KQIQI_CY Order By KQIQI_ID Desc
Rs.Open Sql,Conn,1,3
Datanum=Rs.Recordcount
For i= 1 To Datanum
Title=Replace(Replace(Rs(1),Chr(13),),Chr(10),)
'開始產生成語文件
Set Fso=Createobject(Scripting.FilesyStemobject)
Set KQIQI_MB=Fso.Opentextfile(server.mappath(KQIQI_CY_MB.html))
KQIQI_Ce=KQIQI_MB.readall
KQIQI_MB.close
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Title},&Title&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:SystemTitle},&SystemTitle&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Pinyin},&Rs(2)&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Explain},&Rs(3)&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Content},&Rs(4)&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Record},&Rs(5)&)
Set KQIQI_We=Fso.Createtextfile(Server.Mappath(Html/KQIQICY_&Rs(0)&.html),true)
KQIQI_We.writeline KQIQI_Ce
KQIQI_We.Close
Set Fso=Nothing
'生成完成
Rs.Movenext
Next
KQIQICY = KQIQICY & <TABLE cellSpacing=0 cellPadding=0 width=480 align=center border=0 class=td table> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center><IMG src=images/logo.gif border=0 width=220 height=90></TD></TR> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center class=tdbar>產生完畢</TD></TR> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center>客齊齊成語字典全部生成完畢! <input type=button name=button1value=返回onclick=javascript:history.back(-1);></TD></TR>& vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center class=tdbar>退出</TD></TR> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center><a href=KQIQI_Admin.asp?Action=Quit>退出</a>& vbCrLf
KQIQICY = KQIQICY & </TD></TR></FORM></TABLE> & vbCrLf
第二種,從別的系統看出來的
複製代碼代碼如下:
<%
' Copyright 2007
' 編寫者:吳軍
' 版權所有:www.sm05.com
' 版本:Ver 1.0
' 技術支援:郵件:[email protected] QQ: 21275120
%>
<!--#include file=cyconn.asp-->
<%
dim fso
dim fr
dim wstr
dim fw
'開始HTML產生方式
set rs=server.createobject(adodb.recordset)
sql=select * from pic order by id desc
rs.open sql,conn,1,3
datanum=rs.recordcount
for i= 1 to datanum
'開始產生成語文件
set fso=createobject(scripting.filesystemobject)
set fr=fso.opentextfile(server.mappath(chengyu_m.htm))
wstr=fr.readall
fr.close
dim rstr
wstr=replace(wstr,<{{biaoti}}>,&replace(rs(biaoti),vbnewline,)&)
wstr=replace(wstr,<{{pinyin}}>,&rs(sg)&)
wstr=replace(wstr,<{{jieshi}}>,&rs(js)&)
wstr=replace(wstr,<{{from}}>,&rs(content)&)
wstr=replace(wstr,<{{example}}>,&rs(jilu)&)
set fw=fso.createtextfile(server.mappath(view/chengyu&rs(id)&.htm),true)
fw.writeline wstr
fw.close
set fso=nothing
'生成完成
rs.movenext
next
response.write 來一來論壇成語欄全部生成完畢!
%>
MakeHtml 從指定的id開始生成
複製代碼代碼如下:
'開始HTML產生方式
Set Rs=Server.Createobject(Adodb.Recordset)
Sql=Select KQIQI_ID,KQIQI_Title,KQIQI_Pinyin,KQIQI_Explain,KQIQI_Content,KQIQI_Record From KQIQI_CY Order By KQIQI_ID Desc
Rs.Open Sql,Conn,1,3
For i=id1 To id2
Title=Replace(Replace(Rs(1),Chr(13),),Chr(10),)
'開始產生成語文件
Set Fso=Createobject(Scripting.FilesyStemobject)
Set KQIQI_MB=Fso.Opentextfile(server.mappath(KQIQI_CY_MB.html))
KQIQI_Ce=KQIQI_MB.readall
KQIQI_MB.close
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Title},&Title&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:SystemTitle},&SystemTitle&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Pinyin},&Rs(2)&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Explain},&Rs(3)&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Content},&Rs(4)&)
KQIQI_Ce=Replace(KQIQI_Ce,{$KQIQI:Record},&Rs(5)&)
Set KQIQI_We=Fso.Createtextfile(Server.Mappath(Html/KQIQICY_&Rs(0)&.html),true)
KQIQI_We.writeline KQIQI_Ce
KQIQI_We.Close
Set Fso=Nothing
'生成完成
Rs.Movenext
Next
KQIQICY = KQIQICY & <TABLE cellSpacing=0 cellPadding=0 width=480 align=center border=0 class=td table> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center><IMG src=images/logo.gif border=0 width=220 height=90></TD></TR> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center class=tdbar>產生完畢</TD></TR> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center>客齊齊成語字典產生完畢! <input type=button name=button1value=返回onclick=javascript:history.back(-1);></TD></TR>& vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center class=tdbar>退出</TD></TR> & vbCrLf
KQIQICY = KQIQICY & <TR><TD align=center><a href=KQIQI_Admin.asp?Action=Quit>退出</a>& vbCrLf
KQIQICY = KQIQICY & </TD></TR></FORM></TABLE> & vbCrLf