本站收录这篇文章通过ASP生成html纯静态页面的简单示例,详细解说文章中相关静态 asp 技术与知识,欢迎能给大家一些在这方面的支持和帮助!下面是详细内容:
原理:通过浏览器传送变量,如
http://127.0.0.1/shengcheng.asp?id=90
代码:
if SaveFile("/new/"&id&".html","http://127.0.0.1/news.asp?id="&id&"") then 中
/new"&id&".html",是你生成的文件和路径。http://127.0.0.1/news.asp?id="&id&""是asp的路径
大家可以自己设置修改,其中 "&id&" 是读取浏览器的变量。网址改成你自己的。
使用方法,给你的文章列表添加一个连接,如 http://127.0.0.1/shengcheng.asp?id=90
90这个变量相信大家会调用吧,这样就能在/new目录下生成按照id排列的html文章了
shengcheng.asp文件如下:
程序代码(For Alixixi.com)如下:
Dim id
id = Request("id")
%>
if SaveFile("/new/"&id&".html","http://127.0.0.1/news.asp?id="&id&"") then
Response.write "已生成"
else
Response.write "没有生成"
end if
function SaveFile(LocalFileName,RemoteFileUrl)
Dim Ads, Retrieval, GetRemoteData
On Error Resume Next
Set Retrieval = Server.CreateObject("Microso" & "ft.XM" & "LHTTP") ‘//把单词拆开防止杀毒软件误杀
With Retrieval
.Open "Get", RemoteFileUrl, False, "", ""
.Send
GetRemoteData = .ResponseBody
End With
Set Retrieval = Nothing
Set Ads = Server.CreateObject("Ado" & "db.Str" & "eam") ‘//把单词拆开防止杀毒软件误杀
With Ads
.Type = 1
.Open
.Write GetRemoteData
.SaveToFile Server.MapPath(LocalFileName), 2
.Cancel()
.Close()
End With
Set Ads=nothing
if err <> 0 then
SaveFile = false
err.clear
else
SaveFile = true
end if
End function
%>
原文:https://www.cnblogs.com/ince/p/10424907.html