将asp页面转换成htm页面

爱覆水难收555

爱覆水难收555

2016-02-19 19:31

生活已是百般艰难,为何不努力一点。下面图老师就给大家分享将asp页面转换成htm页面,希望可以让热爱学习的朋友们体会到设计的小小的乐趣。

  前段时间有个asp页面执行起来很慢,访问人数又颇多,而且又不经常修改,又懒得直接做成静态的,每次都要从服务器下载来改,只好想办法把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")

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

  '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起作用。

  希望对那些正在寻找asp-htm的朋友有用。

(本文来源于图老师网站,更多请访问https://m.tulaoshi.com/webkaifa/)

  http://guanvee.cnblogs.com/archive/2006/06/16/427534.html

展开更多 50%)
分享

猜你喜欢

将asp页面转换成htm页面

Web开发
将asp页面转换成htm页面

把XHTML/CSS页面转换成为打印机页面

Web开发
把XHTML/CSS页面转换成为打印机页面

s8lol主宰符文怎么配

英雄联盟 网络游戏
s8lol主宰符文怎么配

怎么将pdf转换成word 如何将pdf转换成word

pdf
怎么将pdf转换成word 如何将pdf转换成word

怎么将pdf转换成word

电脑网络
怎么将pdf转换成word

lol偷钱流符文搭配推荐

英雄联盟 网络游戏
lol偷钱流符文搭配推荐

怎样将word转换成pdf

电脑网络
怎样将word转换成pdf

怎么将mov转换成mpg

电脑入门
怎么将mov转换成mpg

lolAD刺客新符文搭配推荐

英雄联盟
lolAD刺客新符文搭配推荐

扫雷外挂的设计与实现(四)

扫雷外挂的设计与实现(四)

Excel2010也能处理图片

Excel2010也能处理图片
下拉加载更多内容 ↓