<%
comid=session("comid")
Dim FileName,UrlPath
FileName="../test/"&comid&".htm"
UrlPath ="http://www.abc.com/test/test.asp?comid="&comid
Call SaveToFile(FileName,GetTheHTMLCode(UrlPath))
Response.write UrlPath&" ==> "&FileName&" <br>。。快去看看"
'用XMLHTTP得到源码
Function GetTheHTMLCode(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
GetTheHTMLCode = BytesToBSTR(Http.responseBody,"GB2312")
Set Http=nothing
End Function
'中文乱码处理
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
'保存文件
Sub SaveToFile(FilePath,FileContent)
Dim Fso ,File
Set Fso = Server.CreateObject("Scripting.FileSystemObject")
If (Fso.FileExists(Server.Mappath(FilePath))) Then
Fso.DeleteFile(Server.Mappath(FilePath))
End If
Set File = Fso.createTextFile(Server.Mappath(FilePath))
File.Write (FileContent)
File.Close
Set File=Nothing
Set Fso=Nothing
End Sub
%>