当前位置:主页 > 查看内容

asp中获取内容中所有图片与获取内容中第一个图片的代码

发布时间:2021-05-09 00:00| 位朋友查看

简介:复制代码 代码如下: '===================================== '获取内容中所有图片 '===================================== Function Get_ImgSrc(ByVal t0) Dim t1,Regs,Matches,Match t1="" IF Not(IsNull(t0) Or Len(t0)=0) Then Set Regs=New RegExp Reg……
复制代码 代码如下:

'=====================================
'获取内容中所有图片
'=====================================
Function Get_ImgSrc(ByVal t0)
Dim t1,Regs,Matches,Match
t1=""
IF Not(IsNull(t0) Or Len(t0)=0) Then
Set Regs=New RegExp
Regs.Pattern="<img[^>]+src=""([^"">]+)""[^>]*>"
Regs.Ignorecase=True
Regs.Global=True
Set Matches=Regs.Execute(t0)
IF Matches.Count>0 Then
For Each Match In Matches
IF Left(Match.SubMatches(0),7)<>"http://" Then
t1=t1&"<option value="""&Match.SubMatches(0)&""">"&Match.SubMatches(0)&"</option>"
End IF
Next
End IF
End IF
Get_ImgSrc=t1
Set Matches=Nothing
Set Regs=Nothing
End Function

'=====================================
'获取内容中第一个图片
'=====================================
Function Frist_Pic(ByVal t0)
Frist_Pic=""
Dim Regs,Matches
Set Regs=New RegExp
Regs.Ignorecase=True
Regs.Global=True
Regs.Pattern="<img[^>]+src=""([^"">]+)""[^>]*>"
Set Matches=Regs.Execute(t0)
IF Regs.test(t0) Then
Frist_Pic=Matches(0).SubMatches(0)
End IF
Set Matches=Nothing
Set Regs=Nothing
End Function

原文链接:https://m.jb51.net/article/25893.htm
本站部分内容转载于网络,版权归原作者所有,转载之目的在于传播更多优秀技术内容,如有侵权请联系QQ/微信:153890879删除,谢谢!

推荐图文


随机推荐