ASP生成静态网页各种方法收集整理(2)
发布时间:2008-02-18 19:25:00
标签:静态,静态网页,fso,xmlhttp,adodb
4.自动按模板生成网站首页
<%
Response.Expires = 0
Response.expiresabsolute = Now() - 1
Response.addHeader "pragma", "no-cache"
Response.addHeader "cache-control", "private"
Response.CacheControl = "no-cache"
Response.Buffer = True
Response.Clear
Server.ScriptTimeOut=999999999
on error resume next
'***************************************************************
'* 定义 从模板从读取首页 函数
'* 说明:模板文件名为:index_Template.asp
'***************************************************************
Function GetPage(url)
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
'***************************************************************
'* 生页首页,文件名为:default.htm
'***************************************************************
dim Tstr
Tstr = GetPage("http://www.adhome.net/index_Template.asp")
Set fso = Server.CreateObject("Scripting.FileSystemObject")
Set fout = fso.CreateTextFile(Server.MapPath(".")&"/default.htm")
fout.Write Tstr
fout.close
Response.write"<script>alert(""生成首页成功!\n\n文件名为:default.htm"");location.href="http://www.adhome.net";</script>"
Response.end
%>
5.将asp页面转换成htm页面
<%
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.sina.com.cn"'要读取的页面地址
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.htm")
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 "...<font color=red>更新完成!</font>"
%>
代码算是最简单的,直接保存成一个asp文件即可,只要把URL(要转化的asp地址)和dizhi(要保存的html地址)设置好就可以了,一般这两个文件在同一个目录,才能保证图片或者css、js起作用。


猜你喜欢
- Python中几种常用包比较2、用xlrd包读取Excel文件引用包import xlrd打开文件xlrd.open_workbook(r&
- 安装jieba库教程jieba库是一款优秀的 Python 第三方中文分词库,jieba 支持三种分词模式:精确模式、全模式和搜索引擎模式,
- 简介 SQL Server OS是在Windows之上,用于服务SQL Server的一个
- SQLServer中有五种约束,Primary Key约束、Foreign Key约束、Unique约束、Default约束和Check约束
- 让我们看看如何在 Python 中复制数组。 有 3 种复制数组的方法:只需使用赋值运算符。浅拷贝深拷贝1 使用赋值运算符我们可以使用赋值运
- 最近要做个网页图片批量下载工具,然后需要一个页面显示网页上的所有图片供用户勾选,再根据勾选的内容来下载指定图片,其中就涉及到要到同时显示多张
- 1.图例legend基础语法及用法legend语法参数如下: matplotlib.pyplot.legend(*args, **
- CREATE FUNCTION f_Convert( @str NV
- 一、存储过程存储过程(Stored Procedure)是在大型数据库系统中,一组为了完成特定功能的SQL语句集,经编译后存储在数据库中,用
- 为什么要使用php缓存技术?理由很简单:提高效率。在程序开发中,获取信息的方式主要是查询数据库,除此以外,也可能是通过Web Service
- 写入cookie实例! var u = "value=123"; document.cookie = u; 读取cook
- 哪行哪业都少不了基本功,都说“马步”要扎得稳。在都快说烂了的以目标用户为中心设计的今天,还是要勤练基本功的。不多说了,先了解下“设计的3个C
- 本文分析了让ThinkPHP的模板引擎达到最佳效率的方法。分享给大家供大家参考,具体如下:默认情况下ThinkPHP框架系统默认使用的模板引
- 01 ReplicaSet的架构 前面的文章中,我们说了ReplicaSet的基本概念和限制以及部署前的基本知识。
- 在开发中我们经常遇到这样的需求,需要用户直接点击一个链接进入到一个页面,用户点击后链接后会触发401拦截返回登录界面,登录后又跳转到链接的页
- 在做视觉设计时,如何高效地使用图标是一门学问:该使用什么样的图标?图标该放在哪里?大小如何?图标的使用是否帮助用户更好更快的理解内容,亦或是
- 本文实例为大家分享了树回归的具体代码,供大家参考,具体内容如下#-*- coding:utf-8 -*- #!/usr/bin/python
- 数据加密是一种保护数据安全的技术,通过对数据进行编码,使得未经授权的用户无法读取或改动数据。加密是通过使用加密算法和密钥实现的。加密算法是一
- 一、输出指令ASP的输出指令<% =expression %>显示表达式的值。这个输出指令等同于使用Resp
- 当用人问你MySQL 查询条件中 in 会不会用到索引,你该怎么回答?答案:可能会用到索引 动手来测试下1.创建一张表,给字段port建立索