请问如何加个循环,能显示生成html文件的过程

fwy12 2010-10-08 05:05:42
我用如下代码生成html网页正常,我想加入一个循环,让生成网页的过程显示出来:如果是生成4篇的话,显示如下。
.../html256.html生成完成
.../html257.html生成完成
.../html258.html生成完成
.../html259.html生成完成
然后页面调用info函数。

但是用如下代码后无法循环,仅显示.../html256.html生成完成,页面就不动了,但是四篇文章都生成html。

请问如何加个循环,实现上述显示功能呢。
引用
<!--#include file="../Inc/conn.asp"-->
<!--#include file="admin_check.asp"-->
<%
nd=CheckStr(Trim(request("nd")))
id=CheckStr(Trim(request("id")))
dd=CheckStr(Trim(request("dd")))
xd=CheckStr(Trim(request("xd")))
cd=CheckStr(Trim(request("cd")))
tn=CheckStr(Trim(request("tn")))

mid=CheckStr(Trim(request("mid")))
mxd=CheckStr(Trim(request("mxd")))

function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML"&"2.X"&"MLHTTP")
Http.open "GET",url,false
Http.send()
if Http.readystate<>4 then
exit function
end if
getHTTPPage=bytesToBSTR(Http.responseBody,"GB2312")
set http=nothing
if err.number<>0 then err.Clear
end function

Function BytesToBstr(body,Cset)
dim objstream
set objstream = Server.CreateObject("adodb.stream")
objstream.Type = 1
objstream.Mode =3
objstream.Open
objstream.Write body
objstream.Position = 0
objstream.Type = 2
objstream.Charset = Cset
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function

Sub CreateDefaulthtml()
Dim tRs,tSql
Dim Url,Html
Dim ClassID
dim filename,MDBpath,fso,fout
Server.ScriptTimeout=1000

Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set tRs=server.CreateObject("adodb.recordset")
If ND = 5 then
trs.open "select * from [Yao_Article] Where datediff('d',DateAndTime,now())=0 and yn=0 order by ID desc",conn,3,2
End if

If ND = 4 then
trs.open "select * from [Yao_Article] Where ClassID="&CD&" and yn=0 order by ID desc",conn,3,2
End if
If ND = 3 then
trs.open "select Top "&tn&" ID, * from [Yao_Article] Where yn=0 order by ID desc",conn,3,2
End if
If ND = 2 then
trs.open "select * from [Yao_Article] Where ID="&ID&" and yn=0 order by ID desc",conn,3,2
End if
If ND = 1 then
trs.open "select * from [Yao_Article] Where ID<="&DD&" and ID>="&XD&" and yn=0 order by ID desc",conn,3,2
End if
If ND = 0 then
trs.open "select * from [Yao_Article] Where yn=0 order by ID desc",conn,3,2
End if
While Not tRs.eof
Url="http://"&request.ServerVariables("Server_NAME")&""&SitePath&"html/?"&trs("id")&".html"
Html = getHTTPPage(Url)
filename="../html/"&trs("id")&".html"

'FilePath=Server.Mappath("/")
'Set Fso = Server.CreateObject("Scripting.FileSystemObject")
'If Not Fso.FolderExists(FilePath) Then Fso.CreateFolder (FilePath)

Set fout = fso.CreateTextFile(server.mappath(""&filename&""))
fout.Write html
%>
<%
tRs.movenext
Wend
tRs.close
fout.close
set fout=nothing
set fso=nothing
if err then
err.Clear
response.Write("error")
else
%>
<%=filename%>生成成功....

<%

Call Info("更新成功!")
end if
End Sub

Call CreateDefaulthtml()
%>


...全文
159 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
fwy12 2010-10-10
  • 打赏
  • 举报
回复
还是这样好啊
dahaidao 2010-10-09
  • 打赏
  • 举报
回复
可以这样,生成的时候把信息存到数据库里,
页面每隔一秒去读一下数据库,把信息列出来。
  • 打赏
  • 举报
回复
你的意思是想边生成边显示的

你自己搜索一下吧
gaohangwork 2010-10-09
  • 打赏
  • 举报
回复
能这样就好了
fwy12 2010-10-09
  • 打赏
  • 举报
回复
[Quote=引用 9 楼 dahaidao 的回复:]
可以这样,生成的时候把信息存到数据库里,
页面每隔一秒去读一下数据库,把信息列出来。
[/Quote]

要是能实现这样的就更好了
ChinaXtHuLang 2010-10-09
  • 打赏
  • 举报
回复
Set fout = fso.CreateTextFile(server.mappath(""&filename&"")) 
fout.Write html
%>
<%
tRs.movenext
Response.Write(filename&"<br>")
Response.Flush()
Wend

在创建文件之后。加上
Response.Write(filename&"<br>")
Response.Flush()
phuai007 2010-10-08
  • 打赏
  • 举报
回复
循环开始
response.Write "向 "&Email&" 发送成功<br>"
response.flush
fwy12 2010-10-08
  • 打赏
  • 举报
回复
添加 response.write filename这个后没有反应的。还是生成,没有提示的
leuone 2010-10-08
  • 打赏
  • 举报
回复
就写在filename="../html/"&trs("id")&".html"
后面
fwy12 2010-10-08
  • 打赏
  • 举报
回复
我按照楼上的改了,可是不行啊,运行后一篇空白的,html也没有生成的。
shenzhenNBA 2010-10-08
  • 打赏
  • 举报
回复
在指定位置增加红色部分,去掉兰色部分,其他保持不变,也就是在循环里面加,试看...

。。。其他。。。
err.clear
on error resume next

Set fout = fso.CreateTextFile(server.mappath(""&filename&""))
fout.Write html
if err.number=0 then
response.write filename & " 生成成功...."
else
response.write filename & " 文件建立过程出现意外...."
end if


。。。其他。。。


<%=filename%>生成成功.... '把这里去掉

。。。其他。。。
fwy12 2010-10-08
  • 打赏
  • 举报
回复
具体写在什么位置呢?
leuone 2010-10-08
  • 打赏
  • 举报
回复
要在循环里面写上 response.write filename

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧