<%
'----------Get the content remotely and store the content on the local computer, including any files! ----------
'---------------Using xmlhttp and adodb.stream-----------------
'On Error Resume Next
'----------------------------------Define output format------------------ ---------------
path=request(path)
if path = then
path=http://pcqc.86516.com/index.asp
'The URL defined here is Baidu, please note that there must be a file suffix
end if
sPath = Path
if left(lcase(path),7) <> http:// then
'-------------If there is no http in front, it is a local file and is handed over to LocalFile for processing------------
LocalFile(path)
else
'--------------------------Otherwise, it is a remote file and will be handled by RemoteFile------------------
RemoteFile(Path)
end if
'Response.Write err.Description
'-------------Processing function----------
subLocalFile(Path)
'------------------If it is a local file, simply jump to the page------------------ -
'Response.Redirect Path
An error occurred in Response.write!
End Sub
SubRemoteFile(sPath)
'---------------------------------Remote file processing function----------------------------- ----------
FileName = GetFileName(sPath)
'-------------GetFileName is the process of converting an address into a qualified file name-------------
FileName = Server.MapPath(Cache/ & FileName)
Set objFso = Server.CreateObject(Scripting.FileSystemObject)
'Response.Write fileName
if objFso.FileExists(FileName) Then
'-------------Check whether the file has been accessed, if so, simply jump---------------------
Response.Redirect cache/ & GetFileName(path)
Else
'-------------Otherwise, use the GetBody function to read it first---------------------
'Response.Write Path
t = GetBody(Path)
'-----------------Use binary method to write to the browser-------------------------------- --
Response.BinaryWrite t
Response.Flush
'-----------------Output Buffering--------------------------------- ----------
SaveFile t,GetFileName(path)
'------------------Cache the file content to a local path for next access----------
End if
Set objFso = Nothing
End Sub
Function GetBody(url)
'-----------------------This function is a function for obtaining content remotely----------------- ---
'on error resume next
'Response.Write url
Set Retrieval = CreateObject(Microsoft.XMLHTTP)
'----------------------Create XMLHTTP object------------------------ -----
With Retrieval
.Open Get, url, False, ,
'------------------Send using Get, asynchronous method-----------------------
.Send
'GetBody = .ResponseText
GetBody = .ResponseBody
'------------------Function returns the obtained content--------------------------
End With
Set Retrieval = Nothing
'response.Write err.Description
End Function
Function GetFileName(str)
'--------------------------This function is a qualified file name function-------------- ----
str = Replace(lcase(str),http://,)
str = Replace(lcase(str),//,/)
str = Replace(str,?,)
str = Replace(str,&,)
str = Replace(str,/,)
str = replace(str,vbcrlf,)
GetFileName = str
End Function
sub SaveFile(str,fName)
'--------------------------This function is a function that saves the stream content-------------- ----
'on error resume next
Set objStream = Server.CreateObject(ADODB.Stream)
'-------------To create an ADODB.Stream object, ADO version 2.5 or above is required---------
'objStream.Type = adTypeBinary
objStream.Type = 1
'-------------Open in binary mode-------------------------------- -----
objStream.Open
objstream.write str
'--------------------------Write the string content into the buffer-------------------------- ----
'response.Write fname
'path attention
objstream.SaveToFile E:/webroot/pcqc/vip/UploadFile/cache/&fName,2
'objstream.SaveToFile d:/cache/ & fName,adSaveCreateOverWrite
'--------------------------Write buffered contents to file-------------------------- ----
'response.BinaryWrite objstream.Read
objstream.Close()
set objstream = nothing
'-----------------------Close the object and release resources--------------------- ----
'response.Write err.Description
End sub
function saveimage(from,tofile)
dim geturl,objStream,imgs
geturl=trim(from)
imgs=gethttppage(geturl)'The process of obtaining the specific content of the image
Set objStream = Server.CreateObject(ADODB.Stream)' To create an ADODB.Stream object, ADO 2.5 or above is required
objStream.Type =1'Open in binary mode
objStream.Open
objstream.write imgs' writes the string content into the buffer
objstream.SaveToFile server.mappath(tofile),2'-write the buffered content to the file
objstream.Close()'Close the object
set objstream=nothing
end function
%>