I don't know if this is a general class? I am sorry for the lack of solid ASP basic knowledge.
1. download the following text file and change. txt to. asp, which contains specific settings.
Http://www.dongjidao.com/remote.txt
2. Call method:
<! -- # Include file = "remote. asp" -->
Change the following code to the place where the article is stored
Code: [copy to clipboard] If ssavefileselect = true then
RS ("content") = replaceremoteurl (articlecontent, ssavefilepath, sfileext)
Else
RS ("content") = articlecontent
End if
<% 'Whether to save the remote image const ssavefileselect = true' when adding a resource, do not end with "/" const ssavefilepath = "/images/News" 'Remote Image Storage Type const sfileext = "JPG | GIF | BMP | PNG "'////// ////////////////////////////////////////: replace the remote file in the string with a local file and save the Remote File 'parameter: 'shtml: string to be replaced 'ssavepath: Path of the saved file 'sext: execute the replaced Extension function replaceremoteurl (shtml, ssavefilepath, sfileext) dim s_content = shtml if isobjinstalled ("Microsoft. XMLHTTP ") = false then replaceremoteurl = s_content exit function end if Dim re, remotefile, remotefileurl, savefilename, savefiletype, delimiter, arrsavefilename, ssavefilepaths set Re = new Regexp re. ignorecase = true re. global = true re. pattern = "(HTTP | HTTPS | FTP | RTSP | MMS) :( \// |\\\\) {1} (\ W) + [.]) {1,} (net | com | CN | org | CC | TV | [0-9] {1, 3}) (\ s * \/) (\ s) + [.] {1} ("& sfileext &") "set remotefile = Re. execute (s_content) for each remotefileurl in remotefile savefiletype = Replace (replace (remotefileurl, "/", "A"), ":", "A") arrsavefilename = right (savefiletype, 12) Authorization = ssavefilepath & "/" savefilename = ssavefilepaths & arrsavefilename call saveremotefile (savefilename, remotefileurl) s_content = Replace (s_content, remotefileurl, savefilename) next replaceremoteurl = s_contentend function '//////////////////////////////////: save remote file to local 'parameter: localfilename ------ local file name 'remotefileurl ------ Remote File url' return value: True ---- success 'false---- failure sub saveremotefile (s_localfilename, s_remotefileurl) dim ads, retrieval, getremotedata on error resume next set retrieval = server. createobject ("Microsoft. XMLHTTP ") with retrieval. open "get", s_remotefileurl, false ,"","". send getremotedata =. responsebody end with set retrieval = nothing set ads = server. createobject ("ADODB. stream ") with ads. type = 1. open. write getremotedata. savetofile server. mappath (s_localfilename), 2. cancel (). close () end with set ads = nothingend sub '////////////////////////////////: check whether the component has been installed 'parameter: strclassstring ---- component name' return value: True ---- 'false' installed ---- function isobjinstalled (s_classstring) Not Installed) on Error resume next isobjinstalled = false err = 0 dim xtestobj set xtestobj = server. createobject (s_classstring) If 0 = err then isobjinstalled = true set xtestobj = nothing err = 0end function %>