时间:2021-05-28
具体代码实现:
1.模板文件(html)
复制代码 代码如下:
<html xmlns="http:///stat.php?id=1117055&web_id=1117055" language="JavaScript" charset="gb2312"></script></span>
</body>
</html>
2.处理的文件(asp)
复制代码 代码如下:
<!--#include file="conn.asp"-->
<%Server.ScriptTimeOut=99999999%>
<%
dim action,id,news
Layout="news"
id=request.QueryString("id")
action=request.QueryString("action")
select case action
case "add"
%>
<%
'全部生成html
case "htmlall"
set rs=server.CreateObject("adodb.recordset")
Sql = "Select id from news order by id"
rs.open sql,conn,1,1
do while not rs.eof
FsoFile "news",rs("id")
response.write"<div style='color:#003333;' align='center'>"&rs("id")&"新闻生成HTML成功!</div>"
rs.movenext
loop
rs.close
response.write"<div style='color:#FF0000;' align='center'>全部新闻生成HTML成功!</div></br>"
end select
%>
<%
'生成中文html
Function FsoFile(Layout,ID)
Dim Fso,FilePath,FsoF,FsoH,FsoRs,CreateFilePath
FSOCreateDIR "..\news\" & ID & ""
CreateFilePath = "..\news\" & ID & "" 'HTML所在文件夹
FilePath=Server.Mappath(CreateFilePath) & "\index.html" '定义生成html文件名
Set Fso=Server.CreateObject("Scripting.FileSystemObject")
Set FsoH=Fso.OpenTextFile(Server.Mappath("..\templates\news_show.html"),1,true) '读取模版
Content = FsoH.ReadAll
Set FsoRs = Conn.Execute("select * from news where id="&id)
title=FsoRs("title")
demo=FsoRs("demo")
Content = Replace(Content,"{id}",FsoRs("id"))
Content = Replace(Content,"{title}",FsoRs("title"))
Content = Replace(Content,"{demo}",FsoRs("demo"))
Content = Replace(Content,"{webname}",webname)
Content = Replace(Content,"{icp}",icp)
Content = Replace(Content,"{dianhua}",dianhua)
Content = Replace(Content,"{dizhi}",dizhi)
Content = Replace(Content,"{qq}",qq)
Content = Replace(Content,"{alibaba}",alibaba)
Content = Replace(Content,"{tongji}",tongji)
FsoRs.Close
Set FsoRs=Nothing
set stm = server.createobject("ADODB.Stream")
stm.Charset = "gb2312" '定义编码
stm.Open
stm.WriteText content
stm.SaveToFile FilePath, 2
set stm = nothing
End Function
%>
<%
function FSOCreateDIR(LocalPath)
dim patharr,path_level,i,pathtmp,cpath,CreateDIR,FileObject
on error resume next
LocalPath = Server.MapPath(LocalPath)
LocalPath = replace(LocalPath,"\","/")
set FileObject = server.createobject("Scripting.FileSystemObject")
patharr = split(LocalPath,"/")
path_level = ubound(patharr)
for i = 0 to path_level
if i=0 then pathtmp = patharr(0) & "/" else pathtmp = pathtmp & patharr(i) & "/"
cpath = left(pathtmp,len(pathtmp)-1)
if not FileObject.FolderExists(cpath) then FileObject.CreateFolder(cpath)
next
set FileObject = nothing
if err.number<>0 then
CreateDIR = false
err.Clear
else
CreateDIR = true
end if
end function
%>
3.在后台添加生成静态新闻链接
复制代码 代码如下:
<TD height=20 align="center"><a href="../admin_product/saveaddnews.asp?action=htmlall" target="ggdlab">生成新闻静态</a></TD>
来源于我的博客
http://blog.csdn.net/lingfeng179
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
网站主要分为静态网页和动态网页,静态网页是以HTML语言制作的,而动态网页则是以ASP或PHP或JSP等语言来建设的。简单的说,静态网页是以静态化的页面和代码组
大家知道网站主要是分静态页面类型和动态网页类型。静态页面是以html语言制作,而动态网页则以asp或php等语言制作。简单来讲静态就是以静态化的网页和代码组
众所周知,网站主要是分静态网页和动态网页。静态网页是以HTML语言制作,而动态网页则以ASP或PHP或JSP等语言制作。简而言之,静态网页就是以静态化的页面和代
有接触过网站建设的用户都知道,网站主要分为动态网页与静态网页。静态网页是通过html语言制作的,而动态网页则是由Asp或者是Php等语言制作出来的,简单的说,静
众所周知,网站主要是分静态网页和动态网页。静态网页是以HTML语言制作,而动态网页则以ASP或PHP或JSP等语言制作。简而言之,静态网页就是以静态化的页面和代