最新下载
热门教程
- 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
%>
相关文章
- 《彩色点点战争》推图常用三大主c玩法详解 01-23
- 《燕云十六声》池鱼林木任务攻略 01-23
- 《大连地铁e出行》查看行程记录方法 01-23
- 《明日方舟》2025春节限定干员余角色介绍 01-23
- 《崩坏:星穹铁道》万敌光锥搭配攻略 01-23
- 《燕云十六声》一药千金任务攻略 01-23