关于ASP批量生成HTM的问题,有高手在么?

<!--#includefile="../inc/config.asp"--><!--#includefile="../inc/conn.asp"--><!--#incl... <!--#include file="../inc/config.asp"-->
<!--#include file="../inc/conn.asp"-->
<!--#include file="../inc/code.asp"-->
<!--#include file="../inc/SqlIn.Asp"-->
<!--#include file="../inc/check.asp"-->
<%
dim strUrl,Item_Classid,id,FileName,FilePath,Do_Url,Html_Temp
Html_Temp="<UL>"
For i=1 To 1
Html_Temp = Html_Temp&"<LI>"
Item_Classid = i
FileName = "Index.htm"
FilePath = Server.MapPath("/")&"\"&FileName
Html_Temp = Html_Temp&FilePath&"</LI>"
Do_Url = "http://"
Do_Url = Do_Url&Request.ServerVariables("SERVER_NAME")&"/index.asp"
Do_Url = Do_Url&"?Item_Classid="&Item_Classid

strUrl = Do_Url
dim objXmlHttp
set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET",strUrl,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
Dim objAdoStream
set objAdoStream = Server.CreateObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Open()
objAdoStream.Write(binFileData)
objAdoStream.SaveToFile FilePath,2
objAdoStream.Close()

Next
Html_Temp = Html_Temp&"<UL>"
%>

<%
Response.Write ( "成功生成文件:" )
Response.Write ( "<BR>" )
Response.Write Html_Temp
%>
<head>
<META http-equiv=refresh content=0;url=Admin_sfnews.asp>
</head>

这个ASP文件可以生成首页,我现在想批量将showsf.asp?=xxxxx的文件生成HTM,ASP文件应该怎么写?有高手能给写个代码么?只要能用,立即奉上30分。
展开
 我来答
451182
推荐于2016-05-09 · TA获得超过168个赞
知道小有建树答主
回答量:285
采纳率:0%
帮助的人:239万
展开全部
下面是我的一段程序,你自己修改一下就可以了,不会的话你加我的QQ451182,我们可以多交流

<%dbdns="../"%>
<!--#include file="../inc/conn.asp"-->
<!--#include file="cook.asp"-->
<%if fla0<>1 then
response.write "<script>alert('操作权限出错,您没有权限操作些功能');history.go(-1);</Script>"
Response.End
end if
response.write "处理中,请等待。"
if request("action")="save" then
'===========================================================生成Html
set rs=server.createobject("adodb.recordset")
set rs1=server.createobject("adodb.recordset")
set fso=server.CreateObject("Scripting.FileSystemObject")
'=================================================================
sql="select * from SMT_xxnews" '定义数据
rs.open sql,conn,1,1
do while not rs.eof
id=rs("SMT_id")
ypid=rs("SMT_yp_id")
title=rs("SMT_title")
news=rs("SMT_news")
newssort=rs("SMT_newssort")
ly=rs("SMT_ly")
addr=rs("SMT_addr")
addsj=rs("SMT_date")
if ly<>"" then Ftitle="来源:"&ly&""
if addr<>"" then Ftitle1=Ftitle&" 添加人:"&addr&""
if addsj<>"" then Ftitle2=Ftitle1&" 添加时间:"&addsj&""

folder=year(addsj)&month(addsj)
filename=replace(replace(replace(addsj,"-",""),":","")," ","")&".html"
'书写ASP输出模板
shtml="<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN""><html><head>"&_
"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">"&_
"<title>"&title&" - "&application("citytitle")&"</title></head>"&application("citycss")&"<body topmargin=0>"&_
"<script language=javascript src="&application("cityurl")&"Include/top.asp></script>"&_
"<table width=760 border=0 cellspacing=0 cellpadding=0 align=center>"

sql1="select * from SMT_xxnewssort where SMT_id="&newssort
rs1.open sql1,conn,1,1
if not rs1.eof then
newssortview=" >> <a href="&application("cityurl")&"new_list.asp?id="&rs1("SMT_id")&">"&rs1("SMT_newssort")&"</a>"
else
newssortview=""
end if
rs1.close

shtml=shtml&"<tr><td width=580 valign=top><table width=""98%"" border=0 cellspacing=1 cellpadding=0 align=center>"&_
"<tr><td height=30>当前位置:<a href="&application("cityurl")&"index.asp>首页</a> >> <a href="&application("cityurl")&"news.asp>行业新闻</a>"&newssortview&" >> 正文</td></tr>"&_
"<tr><td height=5></td></tr><tr><td height=40 align=center class=f18><strong>"&title&"</strong></td></tr>"&_
"<tr><td align=right>"&_
"<table width=""100%"" border=0 cellspacing=0 cellpadding=5>"&_
"<tr><td align=right><img src="&application("cityurl")&"img/item.gif border=0 align=absmiddle> <a onclick=""window.print()"" style=""cursor:hand"">我要打印</a>"&_
" <img src="&application("cityurl")&"img/collection.gif border=0 align=absmiddle> <a href=# onClick=""javascript:window.external.AddFavorite('"&application("cityurl")&"Html/xxnews/"&folder&"/"&filename&"','"&title&"');return false"">IE收藏</a>"&_
" <img src="&application("cityurl")&"img/gwb.gif border=0 align=absmiddle> <a href=# onClick=""javascript:window.open('"&application("cityurl")&"collection.asp?tit="&title&"&page=Html/xxnews/"&folder&"/"&filename&"','_n','width=300,height=150');return false"">放入公文包</a>"&_
" <img src="&application("cityurl")&"img/icon_info_01.gif border=0 align=absmiddle> <a href=#book>我要留言</a> "&_
" <img src="&application("cityurl")&"img/icon_info_02.gif border=0 align=absmiddle> <a href=#view>查看留言</a> "&_
"</td></tr></table>"&_
"</td></tr>"&_
"<tr><td height=22 align=center bgcolor=388DFE><font color=#ffffff>"&Ftitle2&"</font></td></tr>"&_
"<tr><td height=10></td></tr>"&_
"<tr><td height=300 valign=top><p style=""line-height:190%"" class=f14>"&news&"</td></tr>"&_
"<tr><td height=20></td></tr>"&_
"<tr><td><table width=""100%"" border=0 cellspacing=1 cellpadding=5 bgcolor=#388DFE>"&_
"<tr><td width=""50%""><font color=white><strong>最新供应信息</strong></font></td>"&_
"<td width=""50%""><font color=white><strong>最新求购信息</strong></font></td></tr>"&_
"<tr bgcolor=#ffffff><td><script language=javascript src="&application("cityurl")&"Include/sca.asp?aid=3&bid=6&cid=26&did=1&eid=1&fid=1></script></td>"&_
"<td><script language=javascript src="&application("cityurl")&"Include/sca.asp?aid=2&bid=6&cid=26&did=1&eid=1&fid=1></script></td></tr>"&_
"</table></td></tr>"&_

"<a name=view></a><tr><td height=5></td></tr>"&_
"<tr><td><table width=""100%"" border=0 cellspacing=1 cellpadding=5 bgcolor=388DFE>"&_
"<tr><td><font color=white><strong>查看留言</strong></font></td></tr>"&_
"<tr><td bgcolor=#ffffff height=20><script language=javascript src="&application("cityurl")&"Include/leaveword_view.asp?sortid=7&tableid="&id&"></script></td></tr>"&_
"</table></td></tr>"&_

"<a name=book></a><tr><td height=5></td></tr>"&_
"<tr><td><table width=""100%"" border=0 cellspacing=1 cellpadding=5 bgcolor=388DFE>"&_
"<tr><td><font color=white><strong>用户留言</strong></font></td></tr>"&_
"<tr><td bgcolor=#ffffff><script language=javascript src="&application("cityurl")&"Include/leaveword.asp?sortid=7&tableid="&id&"&ypid="&ypid&"></script></td></tr>"&_
"</table></td></tr>"&_

"</table></td>"&_

"<td width=180 valign=top bgcolor=#efefef>"&_
"<table width=""100%"" border=0 cellspacing=0 cellpadding=3>"&_
"<tr><td height=25 background="&application("cityurl")&"img/bgtitle.gif class=f14> <strong><font color=#ffffff>站内搜索</font></strong></td></tr>"&_
"<tr><td><script language=javascript src="&application("cityurl")&"Include/search.asp?search=2></script></td></tr>"&_
"<tr><td height=25 background="&application("cityurl")&"img/bgtitle.gif class=f14> <strong><font color=#ffffff>企业动态</font></strong></td></tr>"&_
"<tr><td><script language=javascript src="&application("cityurl")&"Include/news.asp?aid=0&bid=8&cid=24&did=0&eid=0&fid=1&gid=0></script></td></tr>"&_
"<tr><td height=25 background="&application("cityurl")&"img/bgtitle.gif class=f14> <strong><font color=#ffffff>产品推荐</font></strong></td></tr>"&_
"<tr><td><script language=javascript src="&application("cityurl")&"Include/cp.asp?aid=1&bid=4&cid=20&did=1&eid=1&fid=80></script></td></tr>"&_
"<tr><td height=25 background="&application("cityurl")&"img/bgtitle.gif class=f14> <strong><font color=#ffffff>行业动态</font></strong></td></tr>"&_
"<tr><td><script language=javascript src="&application("cityurl")&"Include/news.asp?aid=1&bid=20&cid=20&did=1&eid=0&fid=1&gid=0></script></td></tr>"&_
"</table>"&_

"</td></tr></table>"&_

"<table width=760 border=0 cellspacing=0 cellpadding=0 align=center bgcolor=#ffffff>"&_
"<tr><td height=10></td></tr>"&_
"<tr><td height=2 bgcolor=#4795EC></td></tr>"&_
"<tr><td align=center height=80><script language=javascript src="&application("cityurl")&"Include/bottom.asp></script></td></tr></table>"&_

"</body></html>"

path=server.MapPath("../Html/xxnews/"&folder)
if fso.FolderExists(path)=false then
fso.CreateFolder(path)
end if
path=path&"/"&filename

set ts=fso.OpenTextFile(path,2,true,-2)
ts.writeline""&shtml&""
ts.close
set ts=nothing

rs.movenext
loop
rs.close
'=================================================================
set fso=nothing
set rs1=nothing
set rs=nothing
'==============================================结束
elseif request("action")="del" then ’删除生成的静态文件

set Fs = Server.CreateObject("Scripting.FileSystemObject")
HtmlFolder="../Html/news"
If Fs.folderExists(server.mappath(HtmlFolder)) Then
Fs.DeleteFolder(server.mappath(HtmlFolder))
end if
Fs.Createfolder(server.mappath(HtmlFolder))
HtmlFolder="../Html/xxnews"
If Fs.folderExists(server.mappath(HtmlFolder)) Then
Fs.DeleteFolder(server.mappath(HtmlFolder))
end if
Fs.Createfolder(server.mappath(HtmlFolder))
set fs=nothing

end if
response.redirect"config.asp"
%>
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式