28,406
社区成员
发帖
与我相关
我的任务
分享
<%
set rs=server.createobject("adodb.recordset")
sql="select top 8 * from [News] order by id desc"
rs.open sql,conn,3,2
Function ClearHtml(Content)
Content=Zxj_ReplaceHtml("&#[^>]*;", "", Content)
Content=Zxj_ReplaceHtml("</?marquee[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?object[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?param[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?embed[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?table[^>]*>", "", Content)
Content=Zxj_ReplaceHtml(" ","",Content)
Content=Zxj_ReplaceHtml("&nbs","",Content)
Content=Zxj_ReplaceHtml("‘","",Content)
Content=Zxj_ReplaceHtml("×","",Content)
Content=Zxj_ReplaceHtml("”","",Content)
Content=Zxj_ReplaceHtml("{page};","",Content)
Content=Zxj_ReplaceHtml("“","",Content)
Content=Zxj_ReplaceHtml(" ","",Content)
Content=Zxj_ReplaceHtml(" ","",Content)
Content=Zxj_ReplaceHtml("</?tr[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?th[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?p[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</p[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?a[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?img[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?tbody[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?li[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?span[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?div[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?th[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?td[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?script[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("(javascript|jscript|vbscript|vbs):", "", Content)
Content=Zxj_ReplaceHtml("on(mouse|exit|error|click|key)", "", Content)
Content=Zxj_ReplaceHtml("<\\?xml[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("<\/?[a-z]+:[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?font[^>]*>", "", Content)
Content=Zxj_ReplaceHtml("</?b[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?u[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?i[^>]*>","",Content)
Content=Zxj_ReplaceHtml("</?strong[^>]*>","",Content)
ClearHtml=Content
End Function
Function Zxj_ReplaceHtml(patrn,strng,content)
IF IsNull(content) Then
content=""
End IF
Set regEx = New RegExp
regEx.Pattern = patrn
regEx.IgnoreCase = true
regEx.Global = True
Zxj_ReplaceHtml=regEx.Replace(content,strng)
End Function
xmlfile=server.mappath("news.xml")
Set fso = CreateObject("Scripting.FileSystemObject")
Set MyFile = fso.CreateTextFile(xmlfile,True)
ContentType = "text/XML"
MyFile.WriteLine("<?xml version=""1.0"" encoding=""gb2312""?>")
MyFile.WriteLine("<document>")
MyFile.WriteLine(" <webSite>www.chin56.com</webSite>")
MyFile.WriteLine(" <webMaster>chin56@qq.com</webMaster>")
MyFile.WriteLine(" <updatePeri>720</updatePeri>")
rs.movefirst
while not rs.eof
content=rs("news_content")
content=Replace(content,chr(10),"")
content=Replace(content,chr(13),"")
content=Replace(content,chr(32),"")
content=Replace(content,"""","“")
content=Replace(content,"""","”")
content=ClearHtml(content)
if rs("news_guidance")="" then
Guidance=left(content,80)
else
Guidance=ClearHtml(rs("news_guidance"))
end if
MyFile.WriteLine(" <item>")
MyFile.WriteLine(" <title>"&rs("news_title")&"</title>")
MyFile.WriteLine(" <link>http://www.chin56.com/"&rs("File_url")&"</link>")
MyFile.WriteLine(" <description>"&server.HTMLEncode((Guidance))&"</description>")
MyFile.WriteLine(" <text>"&content&"</text>")
MyFile.WriteLine(" <image />")
MyFile.WriteLine(" <headlineImg />")
MyFile.WriteLine(" <keywords>"&rs("news_stitle")&"</keywords>")
MyFile.WriteLine(" <category>手机</category>")
MyFile.WriteLine(" <author>"&rs("news_editor")&"</author>")
MyFile.WriteLine(" <source>"&rs("news_author")&"</source>")
MyFile.WriteLine(" <pubDate>"&rs("news_date")&"</pubDate>")
MyFile.WriteLine(" </item>")
rs.movenext
wend
rs.close
Set rs = Nothing
conn.close
set conn=Nothing
MyFile.WriteLine("</document>")
MyFile.Close
%>
<script language="JavaScript">
alert('百度新闻xml文件生成成功!');
</script>
<script language="javascript">
<!--
function clock(){i=i-1
if(i>0)setTimeout("clock();",1000);
else self.close();}
var i=0.5
clock();
//-->
</script>