Download all content on the remote page at once
Use method, save the above code as a for example: downfile.asp
Enter on the browser:
http://your address/downfile.asp?url=http://www.baidu.com/index.html
| 'Set the timeout time Server.ScriptTimeout=9999 '####################### 'File Save Function '#################### function SaveToFile(from,tofile) on error resume next dim geturl,objStream,imgs geturl=trim(from) Mybyval=getHTTPstr(geturl) Set objStream = Server.CreateObject("ADODB.Stream") objStream.Type =1 objStream.Open objstream.write Mybyval objstream.SaveToFile tofile,2 objstream.Close() set objstream=nothing if err.number0 then err.Clear end function '####################### 'character processing replacement '#################### function geturlencodel(byval url)' Chinese file name conversion Dim i,code geturlencodel="" if trim(Url)="" then exit function for i=1 to len(Url) code=Asc(mid(Url,i,1)) if codeIf code>255 Then geturlencodel=geturlencodel&"%"&Left(Hex(Code),2)&"%"&Right(Hex(Code),2) else geturlencodel=geturlencodel&mid(Url,i,1) end if next end function '####################### 'XML get remote page start '#################### function getHTTPPage(url) on error resume next dim http set http=Server.createobject("Msxml2.XMLHTTP") Http.open "GET",url,false Http.send() if Http.readystate4 then exit function getHTTPPage=bytes2BSTR(Http.responseBody) set http=nothing if err.number0 then err.Clear end function Function bytes2BSTR(vIn) dim strReturn dim i, ThisCharCode, NextCharCode strReturn = "" For i = 1 To LenB(vIn) ThisCharCode = AscB(MidB(vIn,i,1)) If ThisCharCode strReturn = strReturn & Chr(ThisCharCode) Else NextCharCode = AscB(MidB(vIn,i+1,1)) strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode)) i = i + 1 End If Next bytes2BSTR = strReturn End Function '####################### 'XML gets the remote page to end, this is a common part of all thieves programs '#################### '####################### 'Decompose the address and get the file name '#################### function getFileName(byval filename) if instr(filename,"/")>0 then fileExt_a=split(filename,"/") getFileName=lcase(fileExt_a(ubund(fileExt_a))) if instr(getFileName,"?")>0 then getFileName=left(getFileName,instr(getFileName,"?")-1) end if else getFileName=filename end if end function '####################### 'Get remote page function '#################### function getHTTPstr(url) on error resume next dim http set http=server.createobject("MSXML2.XMLHTTP") Http.open "GET",url,false Http.send() if Http.readystate4 then exit function getHTTPstr=Http.responseBody set http=nothing if err.number0 then err.Clear end function '####################### 'FSO processing function, create directory '#################### Function CreateDIR(ByVal LocalPath) 'The program that creates a directory. If there are multiple levels of directories, creates it one level at a time. On Error Resume Next LocalPath = Replace(LocalPath, "/", "/") Set FileObject = server.CreateObject("Scripting.FileSystemObject") patharr = Split(LocalPath, "/") path_level = UBound(patharr) For I = 0 To path_level If I = 0 Then pathtmp = patharr(0) & "/" Else pathtmp = pathtmp & patharr(I) & "/" cpath = Left(pathtmp, Len(pathtmp) - 1) If Not FileObject.FolderExists(cpath) Then FileObject.CreateFolder cpath Next Set FileObject = Nothing If Err.Number 0 Then CreateDIR = False Err.Clear Else CreateDIR = True End If End Function function GetfileExt(byval filename) fileExt_a=split(filename,".") GetfileExt=lcase(fileExt_a(ubund(fileExt_a))) end function '####################### 'How to get the virtual path '#################### function getvirtual(str,path,urlhead) if left(str,7)="http://" then url=str elseif left(str,1)="/" then start=instrRev(str,"/") if start=1 then url="/" else url=left(str,start) end if url=urlhead&url elseif left(str,3)="../" then str1=mid(str,inStrRev(str,"../")+2) ar=split(str,"../") lv=ubund(ar)+1 ar=split(path,"/") url="/" for i=1 to (ubund(ar)-lv) url=url&ar(i) next url=url&str1 url=urlhead&url else url=urlhead&str end if getvirtual=url end function |