复制代码 代码如下:
<%
'添加资源时是否保存远程图片
Const sSaveFileSelect=True
'远程图片保存目录,结尾请不要加“/”
Const sSaveFilePath="/images/News"
'远程图片保存类型
Const sFileExt="jpg|gif|bmp|png"
'/////////////////////////////////////////////////////
'作 用:替换字符串中的远程文件为本地文件并保存远程文件
'参 数:
' sHTML : 要替换的字符串
' sSavePath : 保存文件的路径
' sExt : 执行替换的扩展名
Function ReplaceRemoteUrl(sHTML, sSaveFilePath, sFileExt)
Dim s_Content
s_Content = sHTML
If IsObjInstalled("Microsoft.XMLHTTP") = False then
ReplaceRemoteUrl = s_Content
Exit Function
End If
Dim re, RemoteFile, RemoteFileurl,SaveFileName,SaveFileType,arrSaveFileNameS,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)
sSaveFilePaths=sSaveFilePath & "/"
SaveFileName = sSaveFilePaths & arrSaveFileName
Call SaveRemoteFile(SaveFileName, RemoteFileurl)
s_Content = Replace(s_Content,RemoteFileurl,SaveFileName)
Next
ReplaceRemoteUrl = s_Content
End Function
'////////////////////////////////////////
内容版权声明:除非注明,否则皆为本站原创文章。