'文字或特定图片模式显示新闻
function shownew(content,ntype)
shownew = ""
if(ntype = 1) then
shownew = shownew &" <TABLE width=100% >"
显示新 = 显示新 &"<TR>"
shownew = shownew &" <TD width=600 style='word-break:break-all' valign=top>"&ShowPic(content)&"</TD>"
显示新 = 显示新 &"</TR>"
显示新 = 显示新 &"<TR>"
shownew = shownew &" <TD valign=top style='word-break:break-all'>"&OnlyWord(content)&"</TD>"
显示新 = 显示新 &"</TR>"
显示新 = 显示新 &"</TABLE>"
elseif (ntype = 2) 那么
shownew = shownew &" <TABLE width='100%'>"
shownew = shownew &"<TR>"
shownew = shownew &" <TD style='word-break:break-all' valign=top>"&OnlyWord(content)&"</TD>"
显示新 = 显示新 &"</TR>"
显示新 = 显示新 &"<TR>"
shownew = shownew &" <TD width=600 valign=top style='word-break:break-all'>"&ShowPic(content)&"</TD>"
显示新 = 显示新 &"</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=顶部>“&OnlyWord(内容)&”</TD>”
显示新 = 显示新 &"</TR>"
shownew = shownew &"</TABLE>"
elseif (ntype = 4) then
shownew = shownew &"<TABLE>"
shownew = shownew &"<TR>"
shownew = shownew &"<TD width=80% valign=top 样式='word-break:break-all'>"&OnlyWord(内容)&"</TD>"
shownew = shownew &"<TD width=100 valign=top>"&ShowPic(content)&"</TD>"
shownew = shownew &"</TR>"
显示新 = 显示新 &"</TABLE>"
别的
shownew = shownew & "<table><tr><td style='word-break:break-all'>"&content&"</td></tr></table>"
end if
end function
'显示提取的图片
函数 ShowPic(strng)
ShowPic = ""
ImageUrl= RegExpExecute(strng)
ImageUrls = Split(ImageUrl,"<BR>")
for i = LBound(ImageUrls) 到 (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>")
接下来
结束函数
'从内容中提取图片
函数 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 '遍历匹配集合。
值=值&Match.SubMatches(2)&Match.SubMatches(3)&Match.SubMatches(4)&"<BR>"
下一个
RegExpExecute = 值
End Function
'删除内容中与图片有关的代码
函数OnlyWord(strng)
设置 re=new 正则表达式
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,"")
设置re=无
结束函数