ASP替换、保存远程图片实现代码剖析_第1页
ASP替换、保存远程图片实现代码剖析_第2页
ASP替换、保存远程图片实现代码剖析_第3页
ASP替换、保存远程图片实现代码剖析_第4页
ASP替换、保存远程图片实现代码剖析_第5页
已阅读5页,还剩3页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、1234567891011121314asp替换、保存远程图片实现代码asp通过函数来实现替换、保存远程图片,完成自动采集图片、提取图片的功能,函数中自动判断重 复图片,智能分析链接路径,并转成成相对的图片地址保存在你指定的网站目录中,我们可将此函数 用在后台的编辑器中,当你复制了含有图片的内容后,本代码会自动帮你上传图片。同时本代码也是 采集程序中的重要处理函数,函数代码如下:function replacesaveremotefile(constr,strinstalldir,strchanneldir,savetf,tisturl)if constr=$false$ or constr=

2、 or strinstalldir= or strchanneldir= thenreplacesaveremotefile=constrexit functionend ifdim tempstr,tempstr2,tempstr3,re,matches,match,tempi,temparray,temparray2set re = new regexpre.ignorecase = truere.global = truere.pattern =set matches =re.execute(constr)for each match in matchesif tempstr thent

3、empstr=tempstr & $array$ & match.valueelsetempstr=match.valueend if15161718192021222324252627282930313233nextif tempstr thentemparray=split(tempstr,$array$)tempstr=for tempi=0 to ubound(temparray)re.pattern =srcs*=s*.+?.(gif|jpg|bmp|jpeg|psd|png|svg|dxf|wmf|tiff)set matches =re.execute(temparray(tem

4、pi)for each match in matchesif tempstr thentempstr=tempstr & $array$ & match.valueelsetempstr=match.valueend ifnextnextend ifif tempstr thenre.pattern =srcs*=s*tempstr=re.replace(tempstr,)end ifset matches=nothingset re=nothingif tempstr= or isnull(tempstr)=true thenreplacesaveremotefile=constr#3536

5、3738394041424344454647484950515253exit functionend iftempstr=replace(tempstr,)tempstr=replace(tempstr,)tempstr=replace(tempstr, ,)dimremotefileurl,savepath,pathtemp,dtnow,strfilename,strfiletype,arrsavefilename,rannum,arr_pathdtnow=now()if savetf=true thensavepath= strchanneldir & / & year(dtnow) &

6、right(0 & month(dtnow),2) & / 链接路径:& savepath & arr_path=split(savepath,/)pathtemp=for tempi=0 to ubound(arr path)if tempi=0 thenpathtemp=arr_path(0) & /elself tempi=ubound(arr path) thenexit for ielsepathtemp=pathtemp & arr_path(tempi) & /end ifif checkdir(pathtemp尸false thenif makenewsdir(pathtemp

7、)=false then#55565758596061626364656667686970717273savetf=falseexit for |end ifend ifnextend if去掉重复图片temparray=split(tempstr,$array$)tempstr=for tempi=0 to ubound(temparray)if instr(lcase(tempstr),lcase(temparray(tempi)1 then tempstr=tempstr & $array$ & temparray(tempi)end ifnexttempstr=right(tempst

8、r,len(tempstr)-7)temparray=split(tempstr,$array$)转换相对图片地址tempstr=for tempi=0 to ubound(temparray)tempstr=tempstr & $array$ & definiteurl(temparray(tempi),tisturl)nexttempstr=right(tempstr,len(tempstr)-7)tempstr=replace(tempstr,chr(0),)temparray2=split(tempstr,$array$)#7677787980818283848586878889909

9、192939475tempstr=图片替换/保存set re = new regexpre.ignorecase = truere.global = truefor tempi=0 to ubound(temparray2)remotefileurl=temparray2(tempi)if remotefileurl$false$ and savetf=true then保存图片arrsavefilename = split(remotefileurl,.)strfiletype=lcase(arrsavefilename(ubound(arrsavefilename)文件类型if strfi

10、letype=asp or strfiletype=asa or strfiletype=aspx or strfiletype=ceror strfiletype=cdx or strfiletype=exe or strfiletype=rar or strfiletype=zipthenuploadfiles=re=constrexit functionend ifrandomizerannum=int(900*rnd)+100strfilename = year(dtnow) & right(0 & month(dtnow),2) & right(0& day(dtnow),2)_|&

11、 right(0 & hour(dtnow),2) & right(0 & minute(dtnow),2) & right(0 &second(dtnow),2) & rannum & . & strfiletypere.pattern =temparray(tempi)959697989910010110210310410510610if saveremotefile(savepath & strfilename,remotefileurl)=true then,*pathtemp=savepath & strfilenameconstr=re.replace(constr,pathtem

12、p)re.pattern=strinstalldir & strchanneldir & /uploadfiles=uploadfiles & | & re.replace(savepath &strfilename,)elsepathtemp=remotefileurlconstr=re.replace(constr,pathtemp)uploadfiles=uploadfiles & | & remotefileurlend ifelself remotefileurl$false$ and savetf=false then不保存图片re.pattern =temparray(tempi)constr=re.replace(constr,remote

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论