为了账号安全,请及时绑定邮箱和手机立即绑定

你好,我该怎么把ASP转成HTML?需要怎么操作?

你好,我该怎么把ASP转成HTML?需要怎么操作?

凤凰求蛊 2021-08-22 18:14:58
我想把ASP转换成HTML格式的页面,不知道怎么办?
查看完整描述

2 回答

?
陪伴而非守候

TA贡献1757条经验 获得超8个赞

利用模板技术把asp转换成html

<%
sub asp2htm()
'定义Recordset对象
Set rs=Server.CreateObject("ADODB.Recordset")
'设置rs的ActiveConnection属性,绑定到连接
Set rs.ActiveConnection = Conn
'设置游标类型
rs.CursorType = 3
sql="select * from article where title='"&title&"'"
rs.open sql
do while not rs.eof
ArticleID=rs("ArticleID")
title=rs("title")
author=rs("Author")
copyfrom=rs("copyfrom")
hits=rs("hits")
updatetime=rs("updatetime")
editor=rs("editor")
content=rs("content")
Key=rs("key")
content = replace(content,"../UploadFiles/","../../UploadFiles/") '解决图片路径问题
'title = Request("title") '获取标题
'content = Request("content") '获取内容
'path = Server.MapPath("html") '保存路径
tnow = now()
fname = year(tnow)&FormatNumber(month(tnow)/100,2,Flase)&FormatNumber(day(tnow)/100,2,Flase)&FormatDateTime(tnow,3)&ArticleID
fname = replace(fname,".","")
fname = replace(fname,":","")
fname = fname & ".htm" '生成HTML文件的文件名

Set fso = CreateObject("Scripting.FileSystemObject")
Set ftemp = fso.OpenTextFile(Server.MapPath("asp2htm/templates.txt"), 1)
TempData = ftemp.ReadAll '读取模板内容
ftemp.Close

TempData = Replace(TempData,"#title#",title) '写入标题
TempData = Replace(TempData,"#content#",content) '写入内容
TempData = Replace(TempData,"happig",author)
TempData = Replace(TempData,"本站原创",copyfrom)
'TempData = Replace(TempData,"#click#",hits)
TempData = Replace(TempData,"2006-11-9 15:56:13",updatetime)
TempData = Replace(TempData,"admin",editor)
TempData = Replace(TempData,"7744",articleid)
TempData = Replace(TempData,"|asp,自动生成,html,优化|",Key)
TempData = Replace(TempData,"7744",ArticleID)

Set fhtml = fso.CreateTextFile(path&"\"&fname)
fhtml.WriteLine TempData '保存文件
fhtml.Close
Set fso = nothing

sql="update Article set content='"&fname&"' where articleid="&cint(articleid)
cmd(sql)
rs.movenext
response.Write("添加"&title&"成功<br>")
response.Clear()
Response.Flush()
loop
call cdb(rs)
'将信息存入数据库略。
end sub
%>



查看完整回答
反对 回复 2021-08-30
  • 2 回答
  • 0 关注
  • 273 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信