文字或特定图片模式显示新闻
function shownew(content,ntype)
shownew = ""
if(ntype = 1) then
shownew = shownew &" <table width=100% >"
shownew = shownew &"<tr>"
shownew = shownew &" <td width=600 style=word-break:break-all valign=top>"&showpic(content)&"</td>"
shownew = shownew &"</tr>"
shownew = shownew &"<tr>"
shownew = shownew &" <td valign=top style=word-break:break-all>"&onlyword(content)&"</td>"
shownew = shownew &"</tr>"
shownew = shownew &"</table>"
elseif (ntype = 2) then
shownew = shownew &" <table width=100%>"
shownew = shownew &"<tr>"
shownew = shownew &" <td style=word-break:break-all valign=top>"&onlyword(content)&"</td>"
shownew = shownew &"</tr>"
shownew = shownew &"<tr>"
shownew = shownew &" <td width=600 valign=top style=word-break:break-all>"&showpic(content)&"</td>"
shownew = shownew &"</tr>"
shownew = shownew &"</table>"
elseif (ntype = 3) then
shownew = shownew &"<table>"
shownew = shownew &"<tr>"
shownew = shownew &"<td width=100 valign=top>"&showpic(content)&"</td>"
shownew = shownew &"<td width=80% style=word-break:break-all valign=top>"&onlyword(content)&"</td>"
shownew = shownew &"</tr>"
shownew = shownew &"</table>"
elseif (ntype = 4) then
shownew = shownew &"<table>"
shownew = shownew &"<tr>"
shownew = shownew &"<td width=80% valign=top style=word-break:break-all>"&onlyword(content)&"</td>"
shownew = shownew &"<td width=100 valign=top>"&showpic(content)&"</td>"
shownew = shownew &"</tr>"
shownew = shownew &"</table>"
else
shownew = shownew & "<table><tr><td style=word-break:break-all>"&content&"</td></tr></table>"
end if
end function
显示提取的图片
function showpic(strng)
showpic = ""
imageurl= regexpexecute(strng)
imageurls = split(imageurl,"<br>")
for i = lbound(imageurls) to (ubound(imageurls) – 1)
showpic = showpic & ("<a href="&imageurls(i)&" target=_blank><image src="&imageurls(i)&" border=0 alt=按此在新窗口浏览图片 onload=javascript:if(this.width>180)this.width=180></a>")
next
end function
从内容中提取图片
function regexpexecute(strng)
dim regex, match, matches 建立变量。
set regex = new regexp 建立正则表达式。
regex.pattern = "(src=)(|"&chr(34)&"| )?(.[^|\s|"&chr(34)&"]*)(\.)(jpg|gif|png|bmp|jpeg)(|"&chr(34)&"|\s|>)?" 设置模式。
regex.pattern = "(src=)(|"&chr(34)&"| )?(.[^| |"&chr(34)&"]*)(\.)(jpg|gif|png|bmp|jpeg)(|"&chr(34)&"| |>)?" 设置模式。
regex.pattern = "(s|s)(r|r)(c|c)=(|"+chr(34)+")(\w|\\|\/|\.)+(|"+chr(34)+"| *|>)?" 设置模式。
regex.ignorecase = true 设置是否区分字符大小写。
regex.global = true 设置全局可用性。
set matches = regex.execute(strng) 执行搜索。
for each match in matches 遍历匹配集合。
values=values&match.submatches(2)&match.submatches(3)&match.submatches(4)&"<br>"
next
regexpexecute = values
end function
删除内容中与图片有关的代码
function onlyword(strng)
set re=new regexp
re.ignorecase =true
re.global=true
re.pattern = "(<)(.[^<]*)(src=)(|"&chr(34)&"| )?(.[^|\s|"&chr(34)&"]*)(\.)(jpg|gif|png|bmp|jpeg)(|"&chr(34)&"|\s|>)(.[^>]*)(>)" 设置模式。
onlyword=re.replace(strng,"")
set re= nothing
end function