濮阳杆衣贸易有限公司

主頁 > 知識庫 > ReSaveRemoteFile函數(shù)之a(chǎn)sp實現(xiàn)查找文件保存替換的代碼

ReSaveRemoteFile函數(shù)之a(chǎn)sp實現(xiàn)查找文件保存替換的代碼

熱門標(biāo)簽:伊春外呼業(yè)務(wù)系統(tǒng) 河北智能外呼系統(tǒng)軟件 調(diào)度系統(tǒng)外呼 電銷機器人源碼網(wǎng)盤下載 綿陽防封電銷卡價格 電銷機器人教育 福建外呼增值業(yè)務(wù)線路 中國辦理電信400電話 宜賓語音外呼系統(tǒng)軟件
'================================================
    '函數(shù)名:ReSaveRemoteFile
    '作  用:查找文件保存替換
    '參  數(shù):Str   ----原字符串
    '參  數(shù):url   ----當(dāng)然網(wǎng)站URL
    '參  數(shù):Dir -----保存目錄
    '參  數(shù):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

標(biāo)簽:河池 銅川 延邊 電商邀評 那曲 優(yōu)質(zhì)小號 新鄉(xiāng) 蘇州

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《ReSaveRemoteFile函數(shù)之a(chǎn)sp實現(xiàn)查找文件保存替換的代碼》,本文關(guān)鍵詞  ReSaveRemoteFile,函數(shù),之,asp,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《ReSaveRemoteFile函數(shù)之a(chǎn)sp實現(xiàn)查找文件保存替換的代碼》相關(guān)的同類信息!
  • 本頁收集關(guān)于ReSaveRemoteFile函數(shù)之a(chǎn)sp實現(xiàn)查找文件保存替換的代碼的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    阳曲县| 昭觉县| 连云港市| 孟村| 中西区| 昌图县| 德昌县| 五河县| 石城县| 彰化县| 长葛市| 吉木萨尔县| 克拉玛依市| 咸阳市| 锡林郭勒盟| 峨边| 宽甸| 鄄城县| 资源县| 吴桥县| 大连市| 信丰县| 本溪市| 当涂县| 敦化市| 平遥县| 宝坻区| 通州区| 万全县| 玛沁县| 宕昌县| 黄陵县| 象州县| 公主岭市| 名山县| 巫山县| 东丰县| 凌云县| 临澧县| 邯郸县| 左权县|