この記事では、主にASPの交換とそれを必要とする友人を参照するための関数コードを共有しています
ASPは機能を使用して、リモート写真を交換および保存し、画像を自動的に収集および抽出する機能を完了し、関数で繰り返し写真を自動的に判断し、リンクパスをインテリジェントに分析し、相対的な画像アドレスに変換してWebサイトディレクトリに保存します指定されたバックグラウンドエディターでこの関数を使用できます。同時に、このコードはコレクションプログラムの重要な処理機能でもあります。
- functionReplaceSavereMotefile(Connt、Strinstalldir、Strchanneldir、Savetf、Tisturl)
- ifconstr = $ false $ orconstr = orstrinstalldir = orstrchanneldir = then
- applateSavereMoteFile = const
- exitFunction
- endif
- dimtempstr、tempstr2、tempstr3、re、matches、match、temppi、temparray、temparray2
- setre = newRegexp
- re.ignorecase = true
- re.global = true
- re.pattern =]>
- setMatches = re.execute(contr)
- foreachmatchinmatches
- iftempstr <> then
- tempstr = tempstr&$ array $&match.value
- それ以外
- tempstr = match.value
- endif
- 次
- iftempstr <> then
- temparray = split(tempstr、$ array $)
- tempstr =
- fortempi = 0toubound(temparray)
- re.pattern = src/s*=/s*。+?/。
- setMatches = re.execute(temparray(tempi))
- foreachmatchinmatches
- iftempstr <> then
- tempstr = tempstr&$ array $&match.value
- それ以外
- tempstr = match.value
- endif
- 次
- 次
- endif
- iftempstr <> then
- re.pattern = src/s*=/s*
- tempstr = re.replace(tempstr、)
- endif
- setMatches = Nothing
- setre =何もない
- iftempstr = orisnull(tempstr)= truethen
- applateSavereMoteFile = const
- exitFunction
- endif
- tempstr =置換(tempstr 、、)
- tempstr = cheplage(tempstr、 '、)
- tempstr =置換(tempstr 、、)
- dimremotefileurl、savepath、pathtemp、dtnow、strfilename、strfiletype、arrsavefilename、rannum、arr_path
- dtnow = now()
- ifsavetf = truethen
- SavePath = strchanneldir&/&year(dtnow)&right(0&month(dtnow)、2)&/
- Response.Writeリンクパス:&SavePath&
- arr_path = split(savepath、/)
- pathtemp =
- fortempi = 0toubound(arr_path)
- iftempi = 0then
- pathtemp = arr_path(0)&/
- Elseiftempi = ubound(arr_path)then
- exitfor
- それ以外
- pathtemp = pathtemp&arr_path(tempi)&/
- endif
- ifcheckdir(pathtemp)= falsethen
- ifmakenewsdir(pathtemp)= falsethen
- savetf = false
- exitfor
- endif
- endif
- 次
- endif
- '複製写真を削除します
- temparray = split(tempstr、$ array $)
- tempstr =
- fortempi = 0toubound(temparray)
- ifinstr(lcase(tempstr)、lcase(temparray(temppi)))<1then
- tempstr = tempstr&$ array $&temparray(temppi)
- endif
- 次
- tempstr = right(tempstr、len(tempstr)-7)
- temparray = split(tempstr、$ array $)
- '相対的な画像アドレスを変換します
- tempstr =
- fortempi = 0toubound(temparray)
- tempstr = tempstr&$ array $&devideiturl(temparray(temppi)、tisturl)
- 次
- tempstr = right(tempstr、len(tempstr)-7)
- tempstr =置換(tempstr、chr(0)、)
- temparray2 = split(tempstr、$ array $)
- tempstr =
- '画像の交換/保存
- setre = newRegexp
- re.ignorecase = true
- re.global = true
- fortempi = 0toubound(temparray2)
- remotefileurl = temparray2(tempi)
- ifremotefileurl <> $ false $ andsavetf = truethen'save画像
- arrsavefilename = split(remotefileurl、。)
- strfiletype = lcase(arrsavefilename(ubound(arrsavefilename))) 'ファイルタイプ
- ifstrfiletype = aspostrfiletype = asaorstrfiletype = aspxorstrfiletype = cerorstrfiletype = cdxorstrfiletype = exeorstrfiletype = rarostrfiletype = zipthen
- uploadfiles =
- applateSavereMoteFile = const
- exitFunction
- endif
- ランダム化
- rannum = int(900*rnd)+100
- strfileName = year(dtnow)&right(0&month(dtnow)、2)&right(0&day(dtnow)、2)&right(dtnow(dtnow)、2)&right(dtnow)、2)&right(0&second(dtnow)、2 )&right(0&second(dtnow)、2)&rannum&。&strfiletype
- re.pattern = temparray(tempi)
- ifsaveremotefile(SavePath&strfileName、remotefileurl)= truethen
- '******************************
- pathtemp = savepath&strfilename
- const = re.replace(connt、pathtemp)
- re.pattern = strinstalldir&strchanneldir&/
- uploadfiles = uploadfiles&|&re.replace(savepath&strfilename、)
- それ以外
- pathtemp = remotefileurl
- const = re.replace(connt、pathtemp)
- 'uploadfiles = uploadfiles&|&remotefileurl
- endif
- ElseifRemoteFileurl <> $ false $ andsavetf = falsethen 'は画像を保存しません
- re.pattern = temparray(tempi)
- const = re.replace(connt、remotefileurl)
- uploadfiles = uploadfiles&|&remotefileurl
- endif
- 次
- setre =何もない
- ifuploadfiles <> then
- uploadfiles = right(uploadfiles、len(uploadfiles)-1)
- endif
- applateSavereMoteFile = const
- エンド機能
関数パラメーター説明:
Const:交換する文字列
パラメーター:savetf:ファイルを保存するかどうか、falseは保存しません、true save
パラメーター:Tisturl:現在のWebページアドレス
上記は、ASPの交換とリモート画像機能を保存するためのコードです。すべての人の学習に役立つことを願っています。