SoFunction
Updated on 2025-04-10

Asp Download all content on the remote page at once

Download all content on the remote page at once
Use the method, save the above code as a for example:
Enter on the browser:
http://your address/?url=/

<%
'Set the timeout time
=9999
'##############
'File saving function
'#############
function SaveToFile(from,tofile)
on error resume next
dim geturl,objStream,imgs
geturl=trim(from)
Mybyval=getHTTPstr(geturl)
Set objStream = ("")
 =1

 Mybyval
 tofile,2
()
set objstream=nothing
if <>0 then 
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 code<0 Then code = code + 65536
If 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
'##############
'XMLGet the remote page to start
'#############
function getHTTPPage(url)
on error resume next
dim http
set http=("")
 "GET",url,false
()
if <>4 then exit function
getHTTPPage=bytes2BSTR()
set http=nothing
if <>0 then 
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 < &H80 Then
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
'##############
'XMLGet the remote page end,This is a common part of the thief program
'#############

'##############
'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(ubound(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=("")
 "GET",url,false
()
if <>4 then exit function
getHTTPstr=
set http=nothing
if <>0 then 
end function

'##############
'FSOProcessing functions,Create a directory
'#############
Function CreateDIR(ByVal LocalPath) 'Programs for creating directories,If there are multiple levels of directories,Then create one level after another
On Error Resume Next
LocalPath = Replace(LocalPath, "\", "/")
Set FileObject = ("")
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 (cpath) Then  cpath

Next
Set FileObject = Nothing
If  <> 0 Then
CreateDIR = False

Else
CreateDIR = True
End If
End Function

function GetfileExt(byval filename)
fileExt_a=split(filename,".")
GetfileExt=lcase(fileExt_a(ubound(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=ubound(ar)+1
ar=split(path,"/")
url="/"
for i=1 to (ubound(ar)-lv)
url=url&ar(i)
next
url=url&str1
url=urlhead&url
else
url=urlhead&str
end if
getvirtual=url
end function

'Sample code

dim dlpath
'Create a folder,In order to store these acquired data
virtual="/downweb/"
truepath=(virtual)

if request("url")<> "" then
url=request("url")
fn=getFileName(url)
urlhead=left(url,(instr(replace(url,"//",""),"/")+1))
urlpath=replace(left(url,instrRev(url,"/")),urlhead,"")
strContent = getHTTPPage(url)
mystr=strContent
Set objRegExp = New Regexp
 = True
 = True
 = "(src|href)=.[^\>]+? "
Set Matches =(strContent)
For Each Match in Matches
str=
str=replace(str,"src=","")
str=replace(str,"href=","")
str=replace(str,"""","")
str=replace(str,"'","")
filename=GetfileName(str)
getRet=getVirtual(str,urlpath,urlhead)
temp=Replace(getRet,"//","**")
start=instr(temp,"/")
endt=instrRev(temp,"/")-start+1
if start>0 then
repl=virtual&mid(temp,start)&" "
' repl&"<br>"
mystr=Replace(mystr,str,repl)

dir=mid(temp,start,endt)
temp=truepath&Replace(dir,"/","\")
CreateDir(temp)
 getRet&"||"&temp&filename&"<br>"
 "Successfully obtained"&amp;filename&amp;"This document<br>"
 "And will"&amp;filename&amp;"Save in"&amp;temp&amp;"&lt;br&gt;&lt;br&gt;"
 "&lt;HR&gt;"
SaveToFile getRet,temp&amp;filename
end if
Next
set Matches=nothing
end if
%&gt;

This is the article about all the content on the remote page of Asp downloads at one time. For more related content of Asp loading remote pages, please search for my previous articles or continue browsing the related articles below. I hope everyone will support me in the future!