最新更新 sitemap 网站制作设计本站搜索
网页设计
国外网站 韩国网站 个人主页 手提袋设计 CSS 网页特效 平面设计 网站设计 Flash CMS技巧 服装网站 php教程 photoshop 画册 服务器选用 数据库 Office
虚拟主机 域名注册 云主机 网页设计 客服QQ:8208442
当前位置:首页 > 编程开发 > asp教程

将asp页面转换成htm页面技巧

日期:11-29    来源:网页设计秀    作者:cnwebshow.com

前段时间有个asp页面执行起来很慢,访问人数又颇多,而且又不经常修改,又懒得直接做成静态的,每次都要从服务器下载来改,只好想办法把asp页面转化成htm静态页面了。。。63X中国设计秀

以前就曾经看到这样的文章,不过没太在意,真正想用的时候很难找到一个合适的,于是在网上搜索了半天终于找到比较合适的代码再加上自己的修改,如下:63X中国设计秀

<%63X中国设计秀
Function GetPage(url) 63X中国设计秀
 '获得文件内容63X中国设计秀
 dim Retrieval63X中国设计秀
 Set Retrieval = CreateObject("Microsoft.xmlHTTP") 63X中国设计秀
 With Retrieval 63X中国设计秀
  .Open "Get", url, False ', "", "" 63X中国设计秀
  .Send 63X中国设计秀
  GetPage = BytesToBstr(.ResponseBody)63X中国设计秀
 End With 63X中国设计秀
 Set Retrieval = Nothing 63X中国设计秀
End Function63X中国设计秀

Function BytesToBstr(body)63X中国设计秀
 dim objstream63X中国设计秀
 set objstream = Server.CreateObject("adodb.stream")63X中国设计秀
 objstream.Type = 163X中国设计秀
 objstream.Mode =363X中国设计秀
 objstream.Open63X中国设计秀
 objstream.Write body63X中国设计秀
 objstream.Position = 063X中国设计秀
 objstream.Type = 263X中国设计秀
 objstream.Charset = "GB2312"63X中国设计秀
 BytesToBstr = objstream.ReadText 63X中国设计秀
 objstream.Close63X中国设计秀
 set objstream = nothing63X中国设计秀
End Function63X中国设计秀

on error resume next63X中国设计秀
Url="http://www.sina.com.cn"'要读取的页面地址63X中国设计秀
response.write "开始更新首页..."63X中国设计秀
wstr = GetPage(Url)63X中国设计秀

'response.write(wstr)63X中国设计秀
Set fs=Server.CreateObject("Scripting.FileSystemObject")63X中国设计秀

'if not MyFile.FolderExists(server.MapPath("/html/")) then 63X中国设计秀
'MyFile.CreateFolder(server.MapPath("/html/"))'63X中国设计秀
'end if63X中国设计秀

'要存放的页面地址63X中国设计秀
dizhi=server.MapPath("index.htm")63X中国设计秀
If (fs.FileExists(dizhi)) Then63X中国设计秀
fs.DeleteFile(dizhi)63X中国设计秀
End If63X中国设计秀

Set CrFi=fs.CreateTextFile(dizhi)63X中国设计秀
Crfi.Writeline(wstr)63X中国设计秀
set CrFi=nothing63X中国设计秀
set fs=nothing63X中国设计秀
response.write "...<font color=red>更新完成!</font>"63X中国设计秀
%>63X中国设计秀

63X中国设计秀
代码算是最简单的,直接保存成一个asp文件即可,只要把URL(要转化的asp地址)

本文引用地址:/bc/article_46465.html
网站地图 | 关于我们 | 联系我们 | 网站建设 | 广告服务 | 版权声明 | 免责声明