最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
asp正则获取html文件图片地址
时间:2022-07-02 23:21:55 编辑:袖梨 来源:一聚教程网
Function getIMG(sString)
Dim sReallyDo, regEx, iReallyDo
Dim oMatches, cMatch
'//定义一个空数组
iReallyDo = -1
ReDim aReallyDo(iReallyDo)
If IsNull(sString) Then
getIMG = ""
Exit Function
End If
sReallyDo = sString
'//格式化HTML代码
sReallyDo = Replace(sReallyDo, vbCr, " ")
sReallyDo = Replace(sReallyDo, vbLf, " ")
sReallyDo = Replace(sReallyDo, vbTab, " ")
sReallyDo = ReplaceAll(sReallyDo, " ", " ", True)
sReallyDo = Replace(sReallyDo, "><", ">" & vbCrLf & "<")
sReallyDo = Replace(sReallyDo, "> <", ">" & vbCrLf & "<")
Set regEx = New RegExp
regEx.IgnoreCase = True
regEx.Global = True
'regEx.MultiLine = True
'//去除onclick,onload等脚本
regEx.Pattern = "s[on].+?=([""|'])(.*?)1"
sReallyDo = regEx.Replace(sReallyDo, "")
'//获取SRC带引号的图片地址
regEx.Pattern = "
Set oMatches = regEx.Execute(sReallyDo)
'//将图片地址存入数组
For Each cMatch in oMatches
iReallyDo = iReallyDo + 1
ReDim Preserve aReallyDo(iReallyDo)
aReallyDo(iReallyDo) = regEx.Replace(cMatch.Value, "$2")
Next
' regEx.MultiLine = False
'//获取SRC不带引号的图片地址
regEx.Pattern = "
Set oMatches = regEx.Execute(sReallyDo)
'//将图片地址存入数组
For Each cMatch in oMatches
iReallyDo = iReallyDo + 1
ReDim Preserve aReallyDo(iReallyDo)
aReallyDo(iReallyDo) = regEx.Replace(cMatch.Value, "$1")
Next
getIMG = aReallyDo
End Function
%>
相关文章
- 王者荣耀侦探能力大测试攻略 王者荣耀侦探能力大测试怎么过 11-22
- 无期迷途主线前瞻兑换码是什么 11-22
- 原神欧洛伦怎么培养 11-22
- 炉石传说网易云音乐联动怎么玩 11-22
- 永劫无间手游确幸转盘怎么样 11-22
- 无期迷途主线前瞻兑换码是什么 无期迷途主线前瞻直播兑换码介绍 11-22