有知道用ASP生成百度新闻XML的吗

ywqxtx 2009-06-10 05:29:39
想成为百度新闻源,但是要制作一个XML文件,嫌手动太麻烦了,想做一个程序用ASP自动生成XML文件,有知道怎么做的吗?

我现在的程序生成XML的时候老提示错误!~


<%
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>

...全文
95 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
lihan6415151528 2009-06-10
  • 打赏
  • 举报
回复
应该能的,类似于java的 HttpClient
ywqxtx 2009-06-10
  • 打赏
  • 举报
回复
上面的程序老是在生产XML的时候中断,好像是文章里面的HTML代码的关系,但,我已经用了上面的清楚html代码的语句了。

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧