function_create.asp
<%
'***********************************
'不支持带form参数的url
'source_url
'target_path 目标路经
'target_file 带路经的目标文件
Function Asp2Html(source_url,target_path,target_file)
set FileSysObject = Server.CreateObject("Scripting.FileSystemObject")
if not FileSysObject.FolderExists(target_path) then
FileSysObject.CreateFolder(target_path)
end if
if FileSysObject.FileExists(target_file) then
FileSysObject.DeleteFile(target_file)
end if
set FileSysObject = nothing
'找到路径
dim server_name
Server_Name = Request.ServerVariables("SERVER_NAME")
if instr(source_url,server_name)<1 and instr(lcase(source_url),"http://")<1 then
source_url="http://" & server_name & source_url
source_url = trim(source_url)
else
'do nothing
end if
'response.write source_url
dim objXmlHttp
'set objXmlHttp = Server.createObject("Microsoft.XMLHTTP")
set objXmlHttp = Server.createObject("MSXML2.ServerXMLHTTP")
objXmlHttp.open "GET",source_url,false
objXmlHttp.send()
Dim binFileData
binFileData = objXmlHttp.responseBody
set objXmlHttp=nothing
Dim objAdoStream
set objAdoStream = Server.createObject("ADODB.Stream")
objAdoStream.Type = 1
objAdoStream.Mode=3
objAdoStream.Open()
objAdoStream.Write(binFileData)
call objAdoStream.SaveToFile(target_file,2)
objAdoStream.Close()
set objAdoStream=nothing
end function
%>
<!--#include file="function_create.asp"-->
<%
dim sUrl
sUrl=http://www.51wsc.com/bbs
tPath="E:Victor"
tFile="E:Victorindex_2.htm"
call Asp2Html(sUrl,tPath,tFile)
%>