zoukankan      html  css  js  c++  java
  • ASP从编辑框中获取图片路径

    此函数可以将html代码里的所有图片路径读取出来,这样就可以将批量获取的图片路径保存到数据库,或者批

    量将图片打上水印,或者批量进行图片缩略,想怎么操作就怎么操作,这样就很方便了。
    如果路径是http://开头的,您还可以使用远程下载文件的函数进行下载。这样就做到了批量下载HTML代码时的

    远程图片或者文件了。
    Function oflink_lcasetag(imgstrng)
     '非凡设计原创361du.net
     '将内容html代码里的标签大写转换成小写
     Dim regEx, Match, Matches '建立变量。
     Set regEx = New RegExp '建立正则表达式。
     regEx.Pattern = "<.+?\>" '设置模式。
     regEx.IgnoreCase = true '设置是否区分字符大小写。
     regEx.Global = True '设置全局可用性。
     Set Matches = regEx.Execute(imgstrng) '执行搜索。
     imgstrng=imgstrng
     For Each Match in Matches '遍历匹配集合。
     imgstrng=replace(imgstrng,Match.Value,lcase(Match.Value))
     Next
     oflink_lcasetag = imgstrng
    End Function
    Function ofink_getsrc(strng)
     '非凡设计原创361du.net
     '批量获取图片路径
     strng=oflink_lcasetag(strng)
     Dim regEx, Match, Matches,values,if_add '建立变量。
     Set regEx = New RegExp '建立正则表达式。
     regEx.Pattern = "src\=.+?\.(gif|jpg|jpeg|jpe|png)"
     regEx.IgnoreCase = true '设置是否区分字符大小写。
     regEx.Global = True '设置全局可用性。
     Set Matches = regEx.Execute(strng) '执行搜索。
     if_add=0
     For Each Match in Matches '遍历匹配集合。
     values=values&Match.Value&"|"
     if_add=1
     Next
     values=replace(values,"src=""","")
     values=replace(values,"src='","")
     values=replace(values,"src=","")
     if if_add=1 then values=left(values,len(values)-1)
     ofink_getsrc = values
    End Function
    此函数使用方法:imglist=ofink_getsrc(content)
    其中content可以是编辑框中包含多张图片的内容
    imglist的结果就是将每个图片用"|"隔开,如:1.jpg|2.jpg|3.jpg
    得到这个结果后就可以使用split函数获取单个图片,要对这些图片做什么操作就自己想了。

    ASP 中 Split 函数的实例

    http://www.blueidea.com/tech/program/2003/734.asp

    如何把路径截取掉,只要文件名称?

      Dim   str,arrTmp    
      str="d:/cc/cc.rar"  
      arrTmp=   split(str,"/")  
      str=arrTmp(UBound(arrTmp))     
      response.write(str)  

  • 相关阅读:
    java+selenium自动化-IE浏览器搭建自动化环境
    python中的opencv
    随机森林参数说明
    剑指offer
    Python中常用的包--sklearn
    Anaconda安装,jupyter notebook 使用说明
    C++中的Public 、Private、Protected 区别
    C++类中的Static关键字二
    C++类中的Static关键字
    c语言二级指针内存模型
  • 原文地址:https://www.cnblogs.com/zlmlovem/p/1687197.html
Copyright © 2011-2022 走看看