- '================================================
- '函数名:ReSaveRemoteFile
- '作 用:查找文件保存替换
- '参 数:Str ----原字符串
- '参 数:url ----当然网站URL
- '参 数:Dir -----保存目录
- '参 数:InSave ------是否保存,True,False
- '返回值:格式化取后的字符串
- '================================================
- Public Function ReSaveRemoteFile(ByVal str, ByVal URL, ByVal Dir,InSave)
- Dim s_Content
- Dim re
- Dim ContentFile, ContentFileUrl
- Dim strTempUrl,strFileUrl,DirTemp,PathTemp,FileTemp,Tempi,TempUrlArray,Arr_Path
- Dim sAllowExtName
- sAllowExtName="rm|swf"
- s_Content = str
- On Error Resume Next
- Set re = New RegExp
- re.IgnoreCase = True
- re.Global = True
- re.Pattern = "((src=|href=)((\S)+[.]{1}(" & sAllowExtName & ")))"
- Set ContentFile = re.Execute(s_Content)
- Dim sContentUrl(), n, i, bRepeat
- n = 0
- For Each ContentFileUrl In ContentFile
- strFileUrl = Replace(Replace(Replace(Replace(ContentFileUrl.Value, "src=", "", 1, -1, 1), "href=", "", 1, -1, 1), "'", ""), Chr(34), "")
- If n = 0 Then
- n = n + 1
- ReDim sContentUrl(n)
- sContentUrl(n) = strFileUrl
- Else
- bRepeat = False
- For i = 1 To UBound(sContentUrl)
- If UCase(strFileUrl) = UCase(sContentUrl(i)) Then
- bRepeat = True
- Exit For
- End If
- Next
- If bRepeat = False Then
- n = n + 1
- ReDim Preserve sContentUrl(n)
- sContentUrl(n) = strFileUrl
- End If
- End If
- Next
- If n = 0 Then
- ReSaveRemoteFile = s_Content
- Exit Function
- End If
- For i = 1 To n
- strTempUrl = sContentUrl(i) : strTempUrl = FormatRemoteUrl(strTempUrl,URL)'得到文件地址
- Response.Write(strTempUrl)
- IF InSave=True then
- Arr_Path=Split(Dir,"/")
- '----------建目录-----------------------
- For Tempi=0 To Ubound(Arr_Path)
- If Tempi=0 Then
- PathTemp=Arr_Path(0) & "/"
- ElseIf Tempi=Ubound(Arr_Path) Then
- Exit For
- Else
- PathTemp=PathTemp & Arr_Path(Tempi) & "/"
- End If
- If CheckDir(PathTemp)=False Then
- If MakeNewsDir(PathTemp)=False Then
- SaveTf=False
- Exit For
- End If
- End If
- Next
- '------------------------------------------------------
- TempUrlArray=Split(strTempUrl,"/")
- '----------检查文件是否存在.如果存在换文件名------------------
- Do while True
- FileTemp=Dir & MakeRandom(5) & TempUrlArray(Ubound(TempUrlArray))'生成随机文件名
- If CheckFile(FileTemp)=False then
- Exit Do
- end if
- loop
- '-------------------------------------------------------------------
- Response.Write(FileTemp)
- If SaveRemoteFile(FileTemp,strTempUrl)=True then
- Response.Write("保存成功")&"<Br>"
- s_Content = Replace(s_Content,sContentUrl(i),FileTemp, 1, -1, 1)'替换地址
- Else
- Response.Write("保存失败")&"<Br>"
- End if
- Else
- s_Content = Replace(s_Content,sContentUrl(i),strTempUrl, 1, -1, 1)'替换地址
- End If
- Next
- Set re = Nothing
- PictureExist = True
- ReSaveRemoteFile = s_Content
- Exit Function
- End Function
ReSaveRemoteFile函数之asp实现查找文件保存替换的代码
2019-10-09 14:24asp代码网 ASP教程
ReSaveRemoteFile函数之asp实现查找文件保存替换的代码
延伸 · 阅读
- 2022-03-02Linux 命令find之查找文件的示例
- 2022-01-24C++编程使用findfirst和findnext查找及遍历文件实现示
- 2021-10-20关于ASP网页无法打开的解决方案
- 2021-10-14让apache也支持asp环境的方法
- 2021-08-15asp取整数mod 有小数的就自动加1
- 2021-08-15asp与php中定时生成页面的思路与代码
- ASP教程
最小asp后门程序
这个代码,一般不会 被病毒查杀,而且文件比较小,不容易被怀疑,可以放到别的asp文件中,起到隐藏的目的 ...
- ASP教程
使用ASP记录在线用户的数量的代码
网络的访问量是每一个做网站的网友们都非常关心的问题。如何得知有多少个人正在访问你的网站呢?如何将每天的访问量记录下来?下面就是一个解决方...
- ASP教程
一个改进的ASP生成SQL命令字符串类的代码[已测]
网上找资料发现的,但是调试的时候发现有一些问题,改了一下,还有一定的问题,但是可以做一般使用了。没有考虑数据类型的问题,还有SQL Server 和a...
- ASP教程
asp最简单最实用的计数器
刚才找一个计数器,由于网站的访问量太少,放个计数器在那里确实有点寒酸了,于是呼只能搞一个简单点的,可以访问一次就记录一次的来撑撑门面先。...
- ASP教程
asp 采集实战代码
最近实在是太流行采集了,本人是不喜欢采集的,但对采集的原理我却很有兴趣进行研究,拿到了网上采集常用函数,对其进行了一番研究,并实战,结果...
- ASP教程
asp 标记字符串中指定字符变色不区分大小写
今天遇到这种问题,单纯的使用replace函数不行,他会改变原有的字符串的大小写,在网上找到相关的代码,自己备份下...
- ASP教程
ASP编程入门进阶(五):内置对象Response
通过对Request对象的学习,可以了解到,Request对象是服务器端用来获取客户端的信息的。 但作为服务器和客户端进行交互,是不是还缺少服务器端向客户端...
- ASP教程
CreateKeyWord asp实现的由给定的字符串生成关键字的代码
CreateKeyWord asp实现的由给定的字符串生成关键字的代码 ...