更多免费资源请关注久留免费网:
http://www.96ew.com/
让你轻松把动态网站转换成静态页面
完整代码如下:
<%
'生成静态页面
Sub AspToHtml(ByVal rUrl, ByVal filename)
SaveToFile GetHttpPage(rUrl), Server.MapPath(filename)
End Sub
'获取远程页面内容
Function GetHttpPage(ByVal HttpUrl)
Dim oHttp
On Error Resume Next
Set oHttp=Server.CreateObject("MSXML2.XMLHTTP")
With oHttp
.open "GET",HttpUrl,False
.setrequestheader "Charset", "UTF-8"
.send()
If .Readystate=4 And .Status=200 then
GetHttpPage = BytesToBSTR(.ResponseBody,"GB2312")
Else
GetHttpPage = "读取文件出错!"
End if
End With
Set oHttp=Nothing
If Err then Err.Clear
On Error Goto 0
End Function
' 字节转换成字符
Function BytesToBstr(ByVal Body,ByVal Cset)
Dim oStream
Set oStream = Server.CreateObject("ADODB.STREAM")
With oStream
.Type = 1
.Mode =3
.Open
.Write body
.Position = 0
.Type = 2
.Charset = Cset
BytesToBstr = .ReadText
.Close
End With
Set oStream = Nothing
End Function
' 保存文件
Function SaveToFile(ByVal sText,ByVal sFile)
Dim oStream
On Error Resume Next
Set oStream = Server.CreateObject("ADODB.Stream")
If Err Then
Response.Write("<li/>您的服务器不支持Stream组件!<li/>")
Response.End()
End If
With oStream
.Type = 2
.Open
.Charset = "GB2312"
.Position = 0
.WriteText = sText
.SaveToFile Server.MapPath(sFile),2
.Close
End With
Set oStream = Nothing
End Function
%>
如果您发现本免费资源已过期,请点击报告错误提交过期信息,谢谢!