哪位有ASP生成静态页面的案例,麻烦借我看看
- 提问者网友:风月客
- 2021-05-31 23:44
- 五星知识达人网友:你可爱的野爹
- 2021-06-01 01:19
- 1楼网友:孤独的牧羊人
- 2021-06-01 02:37
生成静态感觉比较麻烦,需要用模板的形式,单页生成很简单!
<% Function GetPage(url) '获得文件内容 dim Retrieval Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", url, False ', "", "" .Send GetPage = BytesToBstr(.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
on error resume next Url=" http://www.XXXX.com/index.asp"'要读取的页面地址 response.write "开始更新首页..." wstr = GetPage(Url)
'response.write(wstr) Set fs=Server.CreateObject("Scripting.FileSystemObject")
'if not MyFile.FolderExists(server.MapPath("/html/")) then 'MyFile.CreateFolder(server.MapPath("/html/"))' 'end if
'要存放的页面地址 dizhi=server.MapPath("index.html") If (fs.FileExists(dizhi)) Then fs.DeleteFile(dizhi) End If
Set CrFi=fs.CreateTextFile(dizhi) Crfi.Writeline(wstr) set CrFi=nothing set fs=nothing response.write "更新完成!" response.End() %>
保存为asp就行,需要生成,执行一下这个文件!
有条件可以使用伪静态,设置服务器就可以,很简单!