本文講述的是用ASP技術(shù)來(lái)獲取指定頁(yè)面中的第一張圖片的地址,下面就說(shuō)說(shuō)函數(shù)的參數(shù)用法:
‘code要檢測(cè)的代碼,可以是地址
‘leixing html 或者ubb
‘nopic 代碼沒(méi)有圖片時(shí)默認(rèn)值
function toppic(code,leixing,nopic)
set regex = new regexp
regex.ignorecase = true
regex.global = true
if leixing = “html” then
regex.pattern = “<img(.*?)srcs?=s?(u0022?)([^u0022/>]+)”
else
regex.pattern = “[img]([^u005B]+)“
end if
set matches = regex.execute(code)
if regex.test(code) then
if leixing = “html” then
toppic = matches(0).submatches(3)
else
toppic = matches(0).submatches(0)
end if
else
toppic = nopic
end if
end function
code1 = “<img src=””1.gif””>”
pic = toppic(code1,”html”,”nopic.gif”)
response.Write pic