如今越來(lái)越多的人開(kāi)始寫(xiě)起了博客,博客應(yīng)該是個(gè)性張揚(yáng)的,應(yīng)該反應(yīng)博客主人對(duì)生活的某種認(rèn)知,要以原創(chuàng)的內(nèi)容為主。只有寫(xiě)出了個(gè)性,寫(xiě)出有價(jià)值的內(nèi)容的博客才是可看的博客。在發(fā)表了一篇文章后,如何讓別人第一時(shí)間知道呢?RSS訂閱功能就可以實(shí)現(xiàn)了。
比如國(guó)內(nèi)知名的博客,新浪博客、搜狐博客、網(wǎng)易博客、BLOGBUS、MSN、WordPress等博客系統(tǒng)均有RSS訂閱功能。RSS訂閱是構(gòu)成良好的博客、用戶互動(dòng)的一個(gè)體現(xiàn)。這些博客自身都帶有RSS訂閱功能,只要在后臺(tái)簡(jiǎn)單的設(shè)置一下就可以讓用戶訂閱RSS內(nèi)容了。
就是flymorn采用asp語(yǔ)言寫(xiě)的一個(gè)博客程序。之前飄易博客并沒(méi)有增加RSS訂閱功能。雖然說(shuō),咱的博客剛開(kāi)張沒(méi)多久,也不確定有多少人會(huì)訂閱本博客,但我相信,只要是用心寫(xiě)的博客,就會(huì)有用戶來(lái)訂閱你的博客。
<%
''連接數(shù)據(jù)庫(kù)
On Error Resume Next '防暴庫(kù)
dim db,conn,connstr
db="數(shù)據(jù)庫(kù)路徑"
set conn= Server.CreateObject("ADODB.Connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath(""&db&"")
conn.Open connstr
strURL = "http://" & request.servervariables("server_name") & _
left(request.servervariables("script_name"),len(request.servervariables("SCRIPT_NAME"))-len("/rss.asp"))
''獲取當(dāng)前域名,其中rss.asp為你的文件名
sql="select top 10 * from [數(shù)據(jù)表名] order by id desc"
''根據(jù)自己實(shí)際修改
set rs=server.createobject("adodb.recordset")
rs.open sql,conn,1,1
response.contenttype="text/xml"
response.write "<?xml version=""1.0"" encoding=""gb2312"" ?>" & vbcrlf
''response.write "<?xml-stylesheet type=""text/xsl"" href=""rss.xsl"" version=""1.0"" ?>" & vbcrlf ''此句即增加xml的樣式表
response.write "<rss version=""2.0"">" & vbcrlf
response.write "<channel>" & vbcrlf
response.write "<title>飄易博客 RSS feed</title>" & vbcrlf
response.write "<link>" & strURL & "</link>" & vbcrlf
response.write "<language>zh-cn</language>" & vbcrlf
response.write "<copyright>An RSS feed for 飄易博客(Www.Piaoyi.Org)</copyright>" & vbcrlf
while not rs.eof
response.write "<item>" & vbcrlf
response.write "<title><![CDATA[" & rs("標(biāo)題") & "]]></title>" & vbcrlf
response.write "<link>"&strURL& rs("路徑") &"</link>" & vbcrlf
response.write "<description><![CDATA[" & rs("摘要或內(nèi)容") & "<br /><br />[<a href="""&strURL& rs("評(píng)論URL") &""">對(duì)“"& rs("標(biāo)題") &"”發(fā)表評(píng)論</a>]<br /><br />]]></description>" & vbcrlf
response.write "<pubDate>" & return_RFC822_Date(rs("時(shí)間"),"GMT") & "</pubDate>" & vbcrlf
response.write "</item>" & vbcrlf
rs.movenext
wend
response.write "</channel>" & vbcrlf
response.write "</rss>" & vbcrlf
rs.close
set rs=nothing
''關(guān)閉數(shù)據(jù)庫(kù)
conn.close
set conn=nothing
''時(shí)間轉(zhuǎn)換函數(shù)
Function return_RFC822_Date(byVal myDate, byVal TimeZone)
Dim myDay, myDays, myMonth, myYear
Dim myHours, myMinutes, mySeconds
myDate = CDate(myDate)
myDay = EnWeekDayName(myDate)
myDays = Right("00" & Day(myDate),2)
myMonth = EnMonthName(myDate)
myYear = Year(myDate)
myHours = Right("00" & Hour(myDate),2)
myMinutes = Right("00" & Minute(myDate),2)
mySeconds = Right("00" & Second(myDate),2)
return_RFC822_Date = myDay&", "& _
myDays&" "& _
myMonth&" "& _
myYear&" "& _
myHours&":"& _
myMinutes&":"& _
mySeconds&" "& _
" " & TimeZone
End Function
''星期轉(zhuǎn)換函數(shù)
Function EnWeekDayName(InputDate)
Dim Result
Select Case WeekDay(InputDate,1)
Case 1:Result="Sun"
Case 2:Result="Mon"
Case 3:Result="Tue"
Case 4:Result="Wed"
Case 5:Result="Thu"
Case 6:Result="Fri"
Case 7:Result="Sat"
End Select
EnWeekDayName = Result
End Function
''月份轉(zhuǎn)換函數(shù)
Function EnMonthName(InputDate)
Dim Result
Select Case Month(InputDate)
Case 1:Result="Jan"
Case 2:Result="Feb"
Case 3:Result="Mar"
Case 4:Result="Apr"
Case 5:Result="May"
Case 6:Result="Jun"
Case 7:Result="Jul"
Case 8:Result="Aug"
Case 9:Result="Sep"
Case 10:Result="Oct"
Case 11:Result="Nov"
Case 12:Result="Dec"
End Select
EnMonthName = Result
End Function
%>
把以上代碼保存為rss.asp文件,修改其中相應(yīng)的數(shù)據(jù)庫(kù)表字段后,即可成功輸出RSS格式的XML文檔?,F(xiàn)在你可以預(yù)覽以下你做好的rss文件了,是不是效果出來(lái)了,純代碼亦可參考
。Feedsky是一家Feed管理服務(wù)商,我們提供給Blogger(博客)、網(wǎng)站(Website)和商業(yè)出版等內(nèi)容出版者在線的服務(wù)平臺(tái),幫助他們加強(qiáng)Feed的優(yōu)化和傳播管理。我們提供跟蹤系統(tǒng)來(lái)追蹤Feed被傳播的渠道,例如閱讀器、網(wǎng)站、新聞組、博客、Email和手機(jī)等,并最終幫助內(nèi)容提供者通過(guò)這些傳播渠道獲取收益。Feedsky會(huì)處理您的Feed格式,使您的Feed能夠自動(dòng)適應(yīng)各種RSS格式以及各種閱讀器,同時(shí)我們會(huì)幫助您建立一個(gè)面向您讀者的訂閱引導(dǎo)頁(yè)面,我們還會(huì)幫您統(tǒng)計(jì)每天、每周和每月的讀者數(shù)量、他們使用的閱讀器種類及文章點(diǎn)擊數(shù)。