关于ASP生成静态页面问题?
我在弄了一个生成静态页面的代码!运行不会出错,也可以生成相应的文件,但是生成的文件里面显示无法找到文件。代码如下:<%response.buffer=true%><!--...
我在弄了一个生成静态页面的代码!运行不会出错,也可以生成相应的文件,但是生成的文件里面显示无法找到文件。
代码如下:
<% response.buffer=true %>
<!--#include file="conn.asp"-->
<%
dim type1,data
type1=request("type")
Server.ScriptTimeOut=30000
dbpath="../../"
set rs=server.createobject("adodb.recordset")
rs.open "Select * From article",conn,1,1
if rs.bof and rs.eof then
response.write "<script>alert('没有任何信息,立即返回!');history.back();</script>"
rs.close:set rs=nothing
conn.close:set conn=nothing
response.end
else
'for i=0 to Rs.recordcount
for i=1 to Rs.recordcount
CPage="article/article.asp?id="&rs("articleid")
CHtml="../article/"&rs("articleid")&".htm"
if Cpage="" then
response.write "<span style=""color:red"">请填写asp文件名</span>"
response.end
end if
if instr(CPage,"http://")>0 then
Url=CPage
else
Url="http://"&Request.ServerVariables("SERVER_NAME")&"/"&CPage
end if
response.write"<br><br>"&Url&""
response.write "<br>开始更新"&CHtml&"..."
wstr = GetPage(Url)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(server.MapPath(CHtml))) Then
fso.DeleteFile(server.MapPath(CHtml))
End If
Set CrFi=fso.CreateTextFile(server.MapPath(CHtml))
Crfi.Writeline(wstr)
set CrFi=nothing
set fso=nothing
rs.movenext
next
rs.close:set rs=nothing
conn.close:set conn=nothing
Server.ScriptTimeOut=60
response.write "<script>alert('生成成功,共生成"&i&"条信息!');history.back();</script>"
end if
Function GetPage(url)
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
Retrieval.Open "Get",url,False ', "", ""
Retrieval.Send
GetPage = BytesToBstr(Retrieval.ResponseBody)
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body)
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 = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
可是我的文件可以生成,就生成的都是相同而且无效的文件! 展开
代码如下:
<% response.buffer=true %>
<!--#include file="conn.asp"-->
<%
dim type1,data
type1=request("type")
Server.ScriptTimeOut=30000
dbpath="../../"
set rs=server.createobject("adodb.recordset")
rs.open "Select * From article",conn,1,1
if rs.bof and rs.eof then
response.write "<script>alert('没有任何信息,立即返回!');history.back();</script>"
rs.close:set rs=nothing
conn.close:set conn=nothing
response.end
else
'for i=0 to Rs.recordcount
for i=1 to Rs.recordcount
CPage="article/article.asp?id="&rs("articleid")
CHtml="../article/"&rs("articleid")&".htm"
if Cpage="" then
response.write "<span style=""color:red"">请填写asp文件名</span>"
response.end
end if
if instr(CPage,"http://")>0 then
Url=CPage
else
Url="http://"&Request.ServerVariables("SERVER_NAME")&"/"&CPage
end if
response.write"<br><br>"&Url&""
response.write "<br>开始更新"&CHtml&"..."
wstr = GetPage(Url)
Set fso=Server.CreateObject("Scripting.FileSystemObject")
If (fso.FileExists(server.MapPath(CHtml))) Then
fso.DeleteFile(server.MapPath(CHtml))
End If
Set CrFi=fso.CreateTextFile(server.MapPath(CHtml))
Crfi.Writeline(wstr)
set CrFi=nothing
set fso=nothing
rs.movenext
next
rs.close:set rs=nothing
conn.close:set conn=nothing
Server.ScriptTimeOut=60
response.write "<script>alert('生成成功,共生成"&i&"条信息!');history.back();</script>"
end if
Function GetPage(url)
dim Retrieval
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
Retrieval.Open "Get",url,False ', "", ""
Retrieval.Send
GetPage = BytesToBstr(Retrieval.ResponseBody)
End With
Set Retrieval = Nothing
End Function
Function BytesToBstr(body)
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 = "GB2312"
BytesToBstr = objstream.ReadText
objstream.Close
set objstream = nothing
End Function
%>
可是我的文件可以生成,就生成的都是相同而且无效的文件! 展开
Storm代理
2023-08-29 广告
2023-08-29 广告
"StormProxies是全球大数据IP资源服务商,其住宅代理网络由真实的家庭住宅IP组成,可为企业或个人提供满足各种场景的代理产品。点击免费测试(注册即送1G流量)StormProxies有哪些优势?1、IP+端口提取形式,不限带宽,I...
点击进入详情页
本回答由Storm代理提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询