asp获取内容中所有图片和第一张图片代码

'===================================== 

'如果未获取到可显示为:

'===================================== 

if Get_ImgSrc(str)="" then

response.write "未找到图片"

else

response.write Get_ImgSrc(str)

end if

'===================================== 

'获取内容中所有图片 

'===================================== 

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

相关文章

数组的定义 Dim MyArray MyArray = Array(1‚5‚123‚12‚98...
\'参数: \'code:要检测的代码 \'leixing:html或者ubb \'n...
演示效果: 代码下载: 点击下载
环境:winxp sp2 ,mysql5.0.18,mysql odbc 3.51 driver 表采...
其实说起AJAX的初级应用是非常简单的,通俗的说就是客户端(j...
<% ’判断文件名是否合法 Function isFilename(aFilename...