function Write2File(sFilePath,sText)
{
var ForReading = 1, ForWriting =2, ForAppending =8;
var fso = Server.CreateObject("Scripting.FileSystemObject");
var f = fso.OpenTextFile(sFilePath,ForWriting,true);
f.Write(sText);
}
var url = Request("url");
//取得解析后的HTML代码.
var strSource = GetSource(url)
//生成的文件地址.防止重名,可自己加入识别.
var sfilePath = Server.MapPath("ttfile.htm");
//写入文件.
Write2File(sfilePath,strSource);
%>
<%
'****************************************************************************
'PageName:GetRemoteFiles.asp
'Function:Download the files to Server
'Author:xiaotian
'Last Modified at:2003-3-19
'****************************************************************************
'取得远程文件并保存到本地
Function GetRemoteFiels(RemotePath, LocalPath, FileName)
Dim strBody
Dim FilePath
On Error Resume Next
'取得流
strBody = GetBody(RemotePath)
'取得保存的文件名
if Right(LocalPath, 1) <> "\" then LocalPath = LocalPath & "\"
FilePath = LocalPath & GetFileName(RemotePath, FileName)
'保存文件
if SaveToFile(strBody, FilePath) = true and err.Number = 0 then
GetRemoteFiles = true
else
GetRemoteFiles = false
end if
End Function
'远程获取内容
Function GetBody(url)
Dim Retrieval
'建立XMLHTTP对象
Set Retrieval = CreateObject("Microsoft.XMLHTTP")
With Retrieval
.open "GET", url
.Send
GetBody = .ResponseBody
End With
Set Retrieval = Nothing
End Function
'重组文件名
Function GetFileName(RemotePath, FileName)
Dim arrTmp
Dim strFileExt
arrTmp = Split(RemotePath, ".")
strFileExt = arrTmp(UBound(arrTmp))
GetFileName = FileName & "." & strFileExt
End Function
'将流内容保存为文件
Function SaveToFile(Stream, FilePath)
Dim objStream