ASP源码
PHP源码
.NET源码
JSP源码
前段时间有个asp页面执行起来很慢,访问人数又颇多,而且又不经常修改,又懒得直接做成静态的,每次都要从服务器下载来改,只好想办法把asp页面转化成htm静态页面了。。。
以前就曾经看到这样的文章,不过没太在意,真正想用的时候很难找到一个合适的,于是在网上搜索了半天终于找到比较合适的代码再加上自己的修改,如下:
<%
Function GetPage(url)
'获得文件内容
dim Retrieval
Set Retrieval = CreateObject("Mi***soft.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 = Se***r.CreateObject("ad***.stream")
ob***ream.Type = 1
ob***ream.Mode =3
ob***ream.Open
ob***ream.Write body
ob***ream.Position = 0
ob***ream.Type = 2
ob***ream.Charset = "GB2312"
BytesToBstr = ob***ream.ReadText
ob***ream.Close
set objstream = nothing
End Function
on error resume next
Url="http://www.sina.com.cn"'要读取的页面地址
re***nse.write "开始更新首页..."
wstr = GetPage(Url)
're***nse.write(wstr)
Set fs=Se***r.CreateObject("Sc***ting.FileSystemObject")
'if not My***e.FolderExists(se***r.MapPath("/html/")) then
'My***e.CreateFolder(se***r.MapPath("/html/"))'
'end if
'要存放的页面地址
dizhi=se***r.MapPath("in***.htm")
If (fs***leExists(dizhi)) Then
fs***leteFile(dizhi)
End If
Set Cr***fs.CreateTextFile(dizhi)
Cr***Writeline(wstr)
set CrFi=nothing
set fs=nothing
re***nse.write "...更新完成!"
%>
代码算是最简单的,直接保存成一个asp文件即可,只要把URL(要转化的asp地址)和dizhi(要保存的html地址)设置好就可以了,一般这两个文件在同一个目录,才能保证图片或者css、js起作用。
希望对那些正在寻找asp->htm的朋友有用。