<%
Dim FileName,UrlPath
FileName="/1.html" '要生成的文件路径及地址
UrlPath ="要生成的网址"
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")
Set File = Fso.createTextFile(Server.Mappath(FilePath))
File.Write (FileContent)
File.Close
Set File=Nothing
Set Fso=Nothing
End Sub
%>
另成为一个.asp文件
浙公网安备 33010602011771号