网络编程 | 站长之家 | 网页制作 | 图形图象 | 操作系统 | 冲浪宝典 | 软件教学 | 网络办公 | 邮件系统 | 网络安全 | 认证考试 | 系统进程
Firefox | IE | Maxthon | 迅雷 | 电驴 | BitComet | FlashGet | QQ | QQ空间 | Vista | 输入法 | Ghost | Word | Excel | wps | Powerpoint
asp | .net | php | jsp | Sql | c# | Ajax | xml | Dreamweaver | FrontPages | Javascript | css | photoshop | fireworks | Flash | Cad | Discuz!
当前位置 > 网站建设学院 > 网络编程 > ASP技巧
Tag:注入,存储过程,分页,安全,优化,xmlhttp,fso,jmail,application,session,防盗链,stream,无组件,组件,md5,乱码,缓存,加密,验证码,算法,cookies,ubb,正则表达式,水印,索引,日志,压缩,base64,url重写,上传,控件,Web.config,JDBC,函数,内存,PDF,迁移,结构,破解,编译,配置,进程,分词,IIS,Apache,Tomcat,phpmyadmin,Gzip,触发器,socket
网络编程:ASP教程,ASP.NET教程,PHP教程,JSP教程,C#教程,数据库,XML教程,Ajax,Java,Perl,Shell,VB教程,Delphi,C/C++教程,软件工程,J2EE/J2ME,移动开发
本月文章推荐
.较长text型数据无法在Asp页面中取.
.将指定的asp文件内容生成HTML文件.
.使用速度更快的OLEDB取代ODBC连结.
.如何判断conn.Execute成功 或失败.
.Excel数据导入到Access,Sql Serv.
.最优化ASP程序性能.
.用ASP和WML来实现数据库查询.
.Connection对象的应用.
.用存储过程实现ASP对数据库访问.
.介绍一下GETROWS的用法.
.利用Page.IsPostBack属性保持用户.
.ASP开发中存储过程应用详解.
.提高ASP页面的执行效率(中).
.ASP.Net中程序构架与程序代码的分.
.构造ConnectionString的方法.
.怎样传送更多的数据在表单中.
.无组件生成BMP验证码.
.随机访问Recordset的一条记录.
.了解MSMQ,控制ASP进程 (二).
.二十八条改善 ASP 性能和外观的技.

动态网站首页的静态生成方法

发表日期:2005-3-7


方法一

<%

'常用函数
'1、输入url目标网页地址,返回值getHTTPPage是目标网页的html代码
function getHTTPPage(url)
dim Http
set Http=server.createobject("MSXML2.XMLHTTP")
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

'2、转换乱玛,直接用xmlhttp调用有中文字符的网页得到的将是乱玛,可以通过adodb.stream组件进行转换
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

 

txtURL=server.MapPath("../index.asp")

sText = getHTTPPage(txtURL)

Set FileObject=Server.CreateObject("Scripting.FileSystemObject")
filename="../index.htm"
Set openFile=FileObject.OpenTextfile(server.mapPath(filename),2,true) 'true为不存在自行建立
openFile.writeline(sText)
Set OpenFile=nothing

%>
<script>
alert("静态网页生成完毕");
history.back();
</script>

方法二:

 resourcefile=server.MapPath("../index.asp")
  targetfile=server.MapPath("../index.htm")
  Set html = Server.CreateObject("CDO.Message")
  html.CreateMHTMLBody resourcefile,31
  indexcode=html.HTMLBody
  Set html = Nothing
if instr(indexcode,"</BODY></HTML>")<=0 then
  response.Write("首页生成失败")
  response.End()
 else
   Set oFileSys = Server.CreateObject("Scripting.FileSystemObject")
   Set outfile=oFileSys.CreateTextFile(targetfile)
   outfile.WriteLine indexcode
   outfile.close  
   Set outfile=nothing
   set oFileSys=nothing
     response.Write("首页生成完毕!")
end if

上一篇:初试WAP之wml+ASP查询 人气:12334
下一篇:使用正则表达式实现模式图片新闻.ASP 人气:12456
浏览全部fso的内容 Dreamweaver插件下载 网页广告代码 祝你圣诞节快乐 2009年新年快乐