首页 > 开发 > Asp > 正文

利用ASP读取RSS

2020-10-03 20:09:31
字体:
来源:转载
供稿:网友

一直想更新一下我的主页,重新改一下版,其中加一个更新功能,把我BLOG里的内容读取过去,空间不支持.NET,只好用ASP操作XML内容,上baidu搜了一下,发现其中几个版本,拿来稍做修改,得以下内容.测试通过,完全可以读取RSS.代码发上来共享:

<style>
body {margin:10px;background-color:#ffffff;margin-top:6px;}
form{margin:0px;}
* {font:12px tahoma;line-height:140%;color:#000000}
.title {font-weight:bold;color:red;}
.time {font:10px;color:#999999;}
a {text-decoration:none;color:blue;}
</style>
<body>
<%
url="这里填写远程RSS的URL,PJblog的feed.asp就是了"

Set xml = Server.CreateObject("Microsoft.XMLHTTP")
xml.Open "GET", url, False
xml.Send

Set xmlDom = server.createObject("microsoft.xmldom")
xmlDom.async=False
xmlDom.ValidateOnParse=false
xmlDom.load(xml.responseXML)

if xmlDom.ReadyState>2 Then  

  set oItem=xmlDom.getElementsByTagName("item")

  for i=0 to oItem.length-5
'设置显示条目数量
    response.write "<span style='font:bold 9px verdana;color:#000000'>"&i+1&"</span>. <a class='title' href='"&oItem(i).childNodes(0).text&"' target='_blank'>"&oItem(i).childNodes(1).text&"</a> <span class='time'>["&oItem(i).childNodes(3).text&"]<br />"
  next
end if
%>

原文地址:http://www.kaoooo.cn/zdp/blog/article.asp?id=46

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表