当前位置: 移动技术网 > IT编程>开发语言>Asp > asp中获取内容中所有图片与获取内容中第一个图片的代码

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

2017年12月08日  | 移动技术网IT编程  | 我要评论
复制代码 代码如下:

'=====================================
'获取内容中所有图片
'=====================================
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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网