顯示具有 feed 標籤的文章。 顯示所有文章
顯示具有 feed 標籤的文章。 顯示所有文章

[教學]給我Live Spaces訪客留言的RSS吧(用Feed43把網頁轉RSS)

此文首發於2007/07/11 20:27 於2008/10/10更新內容

序

首先,雖然不知道RSS融入了多少人的生活~不過我真的覺得RSS是我取得最新資訊的好工具~

話說身為RSS重度使用者的我,把生活與心情的東西用微軟的Live Spaces記錄。

姑且不論Live Spaces速度有點慢這個問題~也不論沒辦法用RSS訂閱最新的文章回應(因為上一篇有談到國良大大用Yahoo Pipes解決了這個問題)(Yahoo Pipes中可搜尋到有人有解決的pipe)~但是它新推出的訪客留言功能居然沒有提供RSS~這樣我怎麼知道有新留言呢~我可不想一直按那個重新整理的按鈕~

所以我就試了幾個免費的服務~最後找到了Feed43這個網站來把我的訪客留言變成RSS Feed~

PS. 最近頁面html有修改~我更新了一下語法~圖沒更新

怎麼做

首先到Feed43選擇【Create your own feed】

輸入要轉為RSS Feed的網址,如我的留言板:http://al080.spaces.live.com/guestbook/

然後點選【Reload】

這時下面會出現網頁的原始碼給大家參考

再來的步驟為輸入轉換的規則,目前Live Spaces的訪客留言板規則如下,將下面這傳碼複製到【Item (repeatable) Search Pattern】

<input type="hidden" id="sn_ccIdCommentControl{%}" value={*}<span dir='ltr'>{%}</span>{*}<div class="Comment" id="sn_ccHtmlCommentControl{*}">{%}</div>{_}</div>{_}<div class="ccDateBox{*}">{*}<span class="ccColor2">{%}</span>

輸入後點選【Extract】,下面就會出現分析的結果

接著到【RSS item properties】下輸入以下欄位內容:

Item Title Template:【{%4} (author: {%2})】

Item Link Template:【http://留言板網址/#sn_ccIdCommentControl{%1}】,如【http://al080.spaces.live.com/guestbook/#sn_ccIdCommentControl{%1}】

Item Content Template:

<div>{%3}</div>
<div>&nbsp;</div>
<div align="right">{%4}</div>

然後點選【Preview】,就可以看到產生的RSS Feed結果

最後你就可以看到Feed的網址,你可以點選【Change file name】讓Feed的網址比較容易記

並且要記得選【Change feed edit password】來設定這個Feed的修改密碼~

結語

雖然這樣就能擁有RSS Feed,不過這樣的做法是治標不治本~

首先因為Feed43產生的Feed沒有時間的欄位~而且如果哪天Live Spaces改掉訪客留言的版面~我們也要跟著修改轉換的規則~

所以還是請大家有需要的人多寫幾封建議信去給網站讓他們提供RSS吧~

相關文章

RSS合併效果比較(RSSMixer與Yahoo Pipes)

序

最近看到了一篇Werboy寫的究極RSS合體術!不管你有多少個RSS,全部幫你合而為一 - RSSMixer

介紹到一個新的RSS合併網站-RSSMixer,專門讓大家能把自己很多個RSS併成一個RSS~

其實這個功能我在管你有幾個Blog,就是要你的最新資訊(Yahoo Pipes+FeedBurner)這篇就有用Yahoo Pipes達成過~

這樣的功能能讓有多個Blog、有Twritter、或是其它服務而有很多個RSS的人~

可以將RSS合併~讓使用者可以一次訂閱你的最新資訊~

當然如同Werboy談到的~也可以把一堆人的RSS或是一堆網站的RSS合併起來方便訂閱~

但我玩了一下RSSMixer後(玩的結果),發現了一些細節上的結果差異~

既然已經有人寫了使用教學~那我也不重複了~

以下就來談談這兩者的差異吧

Yahoo Pipes與RSSMixer的差異

其實這兩者因為方向的不同,所以如果拿製作方式的差異來比可能不是那麼公平~

不過就把RSS合併這方面來看呢~

  • 製作方式的差異
    因為RSSMixer玩全專注在合併這方面,所以使用者就輸入要合併的RSS網址就好了,沒有多餘的東西~
    而Pipes除了合併外,還要加上以日期排序等元件~製作起來步驟比較多~
    而且RSSMixer不用登入就可製作
  • 管理差異
    雖然RSSMixer不用登入就可製作,可以讓使用的時候少掉註冊等事~
    不過確也犧牲掉讓使用者能管理維護自己的RSS功能~所以以後如果要修改就要重建一個RSS了~
    但Pipes原本就可能讓大家修修改改~所以沒這個問題~
  • 網址差異
    Pipes所輸出的結果網址很複雜~
    而RSSMixer則用妳輸入的名稱的英文與數字來產生一個簡短的網址~但如果是全中文名稱則會出現一個亂數的數字的樣子當網址~
  • 篇數差異
    如果按照我的教學用Pipes來合併RSS,基本上如果每個RSS有20篇文章,3個RSS合併後的RSS就會有60篇文章~
    當然~因為Pipes可以客製化的能力比較多,用Operator的【Truncate】元件就可以指定最後輸出的篇數限制~
    而RSSMixer則預設就是25篇了~
  • 內容差異
    基本上Pipes會直接把你的RSS內容輸出~但RSSMixer就我的觀察它好像隱藏掉HTML的內容~
    例如下面這張圖,同樣一篇原本有圖的文章,經過RSSMixer後就沒有圖了,換行也消失~
  • 結果呈現差異
    Pipes在解果呈現時,讓大家可以選用RSS訂閱、My Yahoo、Google、Bloglines...等~
    而RSSMixer另外提供了Apple Dashboard Widget、Web Widget、iPhone等方式來訂閱
    其中的Web Widget是讓你可以用Html與Script放在網站邊邊來呈現結果的功能~不過我覺得這只是加一點語法來呈現RSS~

總結

就複雜度來說,RSSMixer當然是簡單許多~

但為了以後還能修改RSS的來源,我還是會用Yahoo Pipes~

不過現在的RSSMixer還只是Prototype v0.1~

很難說現在的功能就會是以後的功能~

如果只是想很快的合併RSS的話~不妨去玩玩看RSSMixer~

你會發現原來RSS一點也不難用~

管你有幾個Blog,就是要你的最新資訊(Yahoo Pipes+FeedBurner)

序

話說閉關了一陣子,很久沒記錄些新的東西了~

今天跟大家又要跟大家談談RSS了~

其實在網路上逛的人,我想可能有10%有用RSS的習慣就很了不起了,我是覺得好像真的不多人用。

但我個人算是RSS的愛用者,甚至到了沒有RSS會很難過的地步~

為此,我發現了一個有趣的玩法~

不知道大家會不會有個需求~就是像我有兩個Blog,還有使用Twitter...

這些地方都有提供RSS,但是都是分開在各地~

如果我希望觀注我的人能夠一次訂到這些RSS的內容,甚至未來我有新的資訊來源的RSS,訂閱我的人都能在一次訂閱後就能不再需要擔心這些問題~

那麼我該如何做呢~

使用服務

其實我一說出下面兩個服務,明眼人就知道我要做什麼了~

  • Yahoo Pipes:以Web圖形化介面提供邊輯工具,進行RSS的處理、過濾、重組、排序等功能
  • FeedBurner:以自定的網址,提供使用者永久的RSS網址,讓使用者可以訂閱後就不用擔心網站搬家使RSS位址改變的問題,管理者還可得到更多的統計資訊

怎麼做

話說我的資訊來源為

為了要讓使用者可以很容易訂閱,所以我將這些RSS利用Yahoo Pipes組合,過程如下:

先到Yahoo Pipes以Yahoo帳號登入後,點選【Create a pipe】

此時會開啟Yahoo pipes的編輯畫面,在這畫面中可以拖拉的方式設計資料處理邏輯

我們需要的是取得RSS Feed的處理,因此從左邊的Source找到【Fetch Feed】,加到編輯區中

將我需要合併的RSS網址都加到這個元件中

為了讓他產生時能先排序,從Operations找到【Sort】元件,加到編輯區

先將畫面中的三個元件連起來,讓Sort知道他有什麼東西可排序

選擇排序條件:item.pubDate、descending,已發佈時間越新的越上面

然後到右上角選儲存【Save】

第一次儲存他會問要取什麼名字,輸入後選擇【Save】

儲存後,上方會出現【Run Pipe...】,點選他看看結果

這時所出現的就是你的結果,也就是RSS的合併結果。我需要他的RSS,所以點選【Subscribe】→【Get as RSS】。然後複製起來RSS網址,例如我的是【http://pipes.yahoo.com/pipes/pipe.run?_id=LOoSs2Yl3BG9cK_Rl7okhQ&_render=rss】

為了讓使用者好訂閱,未來也不用擔心如果網址變更,還要通知使用者變更。我們到FeedBurner,註冊一個帳號,然後要把剛才的RSS燒成一個新的RSS網址。

將RSS網址貼上後,選擇【Next】

然後輸入名稱與新的RSS網址,選擇【Activate Feed】

成功後就會出現下面的畫面,如果不成功有可能是你選的新RSS網址已有人使用。

如此一來,我就擁有一個把我所有網站新資訊合併後的新RSS【http://feeds.feedburner.com/al080】

延伸應用

當然,既然可以合併RSS,我們就很做很多類似的應用。

例如說,我的兩個Blog,Blogger原本就提供了訂閱最新回應的RSS,而Spaces Live雖然留言的部份是單篇單篇訂閱的,不過搜尋一下,就會發現有位國良大大做的Pipes,可以將你的Spaces Live最新20篇文章的回應RSS抓出來。

用法很簡單,到【http://pipes.yahoo.com/pipes/pipe.info?_id=lJZ2nboZ3BGBoB2pJZhxuA】,會出現要你輸入帳號的地方,像我的Spaces網址是al080開頭,就以此輸入。

然後就跟剛才一樣,可以得到對應的RSS,重複剛才的動作就可以再把Blogger的回應也組合起來,便成了我自己在看有沒有新回應的RSS Feed了唷。

最後的結果就如同我最後產生的這個回應的RSS:http://feeds.feedburner.com/alcomment080

結論

Yahoo Pipes可做的事應該很多,只是我還不太熟悉這樣的開發環境。不過有個好的開始就是不錯的事,大家有興趣可以玩玩看別的方式~像國良大大能將完成那樣就應該很熟了吧~

說真的~RSS的使用到底有多普遍~我真的不知道~

可以發現的是~大多數網站都漸漸的有提供RSS~

可是又會有些例外~像是有些人Blog設為只有朋友才能看~可是這樣卻又不能訂閱他的RSS~這樣子我會逛到他的網站的頻率真的會降很多~

可是有的Blog內容就是希望只有特定人看到~

我覺得這到目前都還很少Blog去解決這件問題~(畢竟RSS用戶是小眾???)

無論如何~我希望未來RSS還會比現在方便~像是回應更方便等~

但我想會出現那樣的事~前提就是使用者更多吧~

比較7個RSS Reader與GreateNews使用教學

序

我個人一直很喜歡用RSS專屬的讀取器訂閱喜歡的內容,

因為它提供我快速且方便的方便得到最新的消息~

不過我最近換了個讀取器,就順手寫篇使用教學~

GreateNews使用教學

到GreatNews下載完後,開啟GreatNews,如下圖選擇語系,並勾選新聞列表

其他細部設定可到【工具】→【選項】裡設定,下面附上參考設定內容

然後如果要新增訂閱,就複製RSS的網址,如http://allen080.blogspot.com/feeds/posts/default?alt=rss

然後在新聞頻道點選右鍵,選擇【新增】→【頻道】

貼上頻道網址,然後選下一步

選擇放在哪個群組

完成後就可選擇該訂閱內容觀看囉

順道一提~我當然是直接將原本SharpReader上的訂閱匯出成OPML,再讓GreatNews匯入的,這部份就不再贅述~

談談為什麼我要用GreatNews

最近我最常用的RSS Reader-SharpReader 0.9.7.0出現了一些讓我不太滿意的Bug

像是我關機時如果沒有手動先把SharpReader關起來~

就會出現錯誤警告~

下回開時它的狀態就會回朔到某個時間~

我之前新增的訂閱就可能會消失掉~

有的時候甚至開啟時就會出問題~

或是開某些網頁(由其是某些人的無名網誌),整個程式就會當在那~

等等小問題~

而我一直忍著希望它的下個版本會更好~

沒想到最近去它的官方網站,居然變成了一個奇怪的購物網~或是進不去~

作者的部落格從去年之後也沒再更新了

所以我就開始尋找有沒有好的RSS Reader...

各RSS Reader使用感

還是先從SharpReader談起,作為基本比較。

  • SharpReader 0.9.7.0
    • 環境簡潔,操作自然
    • 頻道與文章切換速度都算不錯
    • 提供文章文字內容(不直接顯示原始網頁)
    • 各種Feed的資訊顯示完整(有網站縮圖與Comment數量會顯示)
    • 有些Bug

GreatNews是我目前覺得可取代SharpReader,可惜沒有網站縮圖與Comment數量

  • GreatNews 1.0 Beta
    • 環境簡潔,功能齊全
    • 頻道與文章切換速度快
    • 提供文章文字內容(不直接顯示原始網頁)
    • 預設了一些特殊功能,整合Bloglines,且可以外加一些命令,藉此整合一些書籤網站與部落格
    • 可以標簽為文章分類
    • 含中文語系
    • 有免安裝的版本
    • 沒有網站縮圖與Comment數量
    • 只支援單層分類
    • 讀過的文章會先隱藏,要點一下顯示才會顯示(我個人不需這樣的功能,可是沒有選項取消)(把過濾的設定調成全部就沒這個問題了)

RSSOwl則是另一個我覺得不錯的,不過要稍微多調整一下才會符合習慣,且它的分頁有點分過頭了

  • RSSOwl 1.2.3
    • 環境簡潔,功能齊全
    • 頻道與文章切換速度快
    • 提供文章文字內容(不直接顯示原始網頁)
    • 含中文語系
    • 提供分頁瀏覽
    • 有免安裝的版本
    • 沒有網站縮圖與Comment數量
    • 剛啟動時會先花一小段時間載入文章

RSS Bandit其實功能還不錯,還提供遠端儲存功能,可惜效能太差了,連切換速度都不好,還常搞爛我的電腦

  • RSS Bandit
    • 提供遠端儲存,讓多部機器能統一訂閱
    • 環境漂亮,功能齊全
    • 各種Feed的資訊顯示完整(有網站縮圖與Comment數量會顯示)
    • 效能不高,頻道與文章切換速度慢
    • 提供文章文字內容(不直接顯示原始網頁)
  • RSSReader

匯入OPML效能不好...有的文章讀不到內容~淘汰

  • Sauce Reader

不能提供文章文字內容...直接淘汰

  • FeedReader

會有無法解譯的來源,功能也太陽春了~

這兩個都是以郵件為主,附加RSS訂閱,其中Thunderbird在訂閱時,日期的部份有問題,而且介面不夠友善。而Outlook對我而言有點太大了~

總結

用過各家RSS Reader後,雖然最後的結論是GreatNews,

不過它仍然還有加強的空間,

像是支援網站縮圖與Comment數量~

如果可支援遠端儲存會更好等~

我盡我可能試試我有看到的RSS Reader,當然歡迎大家提供更好的選擇給我~

相關連結

用VB.Net寫的RSS Feed產生函式

序

我自己是很喜歡用RSS的服務的人,所以寫網站或是做一些事時常會想到要弄個RSS Feed,最起碼自己會用的到~

不過VB中並沒有直接提供RSS Feed的產生函式,國外有些網站好像有提供類似的東西,不過不是要註冊就是有些複雜,所以我就自己寫了一個~

作法

我原本是用FileIO那篇的寫文字檔的方式,用比較笨的方法產生RSS Feed~

不過後來我改用以下的內容,將RSS的內容,以Xml.XmlDocument這個類別來產生XML的結構,順便學習在VB.Net下怎麼自己產生XML結構,並且它會自己將HTML編碼的問題解決

RSS 2.0的規格則是參考RSS 2.0 Specification中的規定,來設計RSS feed的元素,不過我剔除掉了一些我覺得沒用或是我看不出來功能的標籤,來產生結果

模組程式碼

Imports System
Module RSSGenModule
   ''' 
   ''' RSSGenerator V1.0 is builded by Allen
   ''' Please get the newest information at
   ''' http://allen080.blogspot.com/
   ''' 
   Public Class RSSGenerator
       Public Sub createRSS(ByRef rssfeed As RSSFeed, ByVal path As String)
           'RSS 2.0 specification is Reference at
           'http://www.rssboard.org/rss-specification/
           Dim x As New Xml.XmlDocument
           x.LoadXml("" + "" + "")

           Dim channel As Xml.XmlElement = x.CreateElement("channel")
           x.DocumentElement.AppendChild(channel)

           Dim element As Xml.XmlElement
           Dim subElement As Xml.XmlElement
           'set channel start
           element = x.CreateElement("title")
           channel.AppendChild(element)
           element.InnerText = rssfeed.title
           If Not rssfeed.link Is Nothing Then
               element = x.CreateElement("link")
               channel.AppendChild(element)
               element.InnerText = rssfeed.link
           End If
           If Not rssfeed.description Is Nothing Then
               element = x.CreateElement("description")
               channel.AppendChild(element)
               element.InnerText = rssfeed.description
           End If
           If Not rssfeed.language Is Nothing Then
               element = x.CreateElement("language")
               channel.AppendChild(element)
               element.InnerText = rssfeed.language
           End If
           If Not rssfeed.copyright Is Nothing Then
               element = x.CreateElement("copyright")
               channel.AppendChild(element)
               element.InnerText = rssfeed.copyright
           End If
           If Not rssfeed.managingEditor Is Nothing Then
               element = x.CreateElement("managingEditor")
               channel.AppendChild(element)
               element.InnerText = rssfeed.managingEditor
           End If

           If Not rssfeed.webMaster Is Nothing Then
               element = x.CreateElement("webMaster")
               channel.AppendChild(element)
               element.InnerText = rssfeed.webMaster
           End If

           element = x.CreateElement("pubDate")
           channel.AppendChild(element)
           element.InnerText = (rssfeed.pubDate.AddHours(-8)).ToString("r")

           element = x.CreateElement("lastBuildDate")
           channel.AppendChild(element)
           element.InnerText = (rssfeed.lastBuildDate.AddHours(-8)).ToString("r")

           If Not rssfeed.category Is Nothing Then
               element = x.CreateElement("category")
               channel.AppendChild(element)
               element.InnerText = rssfeed.category
           End If
           If Not rssfeed.generator Is Nothing Then
               element = x.CreateElement("generator")
               channel.AppendChild(element)
               element.InnerText = rssfeed.generator
           End If
           If Not rssfeed.docs Is Nothing Then
               element = x.CreateElement("docs")
               channel.AppendChild(element)
               element.InnerText = rssfeed.docs
           End If


           If Not rssfeed.image Is Nothing Then
               element = x.CreateElement("image")
               channel.AppendChild(element)
               'set image start
               If Not rssfeed.image.title Is Nothing Then
                   subElement = x.CreateElement("title")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.title
               End If
               If Not rssfeed.image.link Is Nothing Then
                   subElement = x.CreateElement("link")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.link
               End If
               subElement = x.CreateElement("url")
               element.AppendChild(subElement)
               subElement.InnerText = rssfeed.image.url
               If Not rssfeed.image.description Is Nothing Then
                   subElement = x.CreateElement("description")
                   element.AppendChild(subElement)
                   subElement.InnerText = rssfeed.image.description
               End If
               'set image end
           End If
           If Not rssfeed.itmes Is Nothing Then
               For Each item As RSSElement In rssfeed.itmes
                   element = x.CreateElement("item")
                   channel.AppendChild(element)
                   'set item start
                   subElement = x.CreateElement("title")
                   element.AppendChild(subElement)
                   subElement.InnerText = item.title
                   If Not item.link Is Nothing Then
                       subElement = x.CreateElement("link")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.link
                   End If
                   If Not item.description Is Nothing Then
                       subElement = x.CreateElement("description")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.description
                   End If
                   If Not item.author Is Nothing Then
                       subElement = x.CreateElement("author")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.author
                   End If
                   If Not item.category Is Nothing Then
                       subElement = x.CreateElement("category")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.category
                   End If
                   If Not item.comments Is Nothing Then
                       subElement = x.CreateElement("comments")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.comments
                   End If
                   If Not item.guid Is Nothing Then
                       subElement = x.CreateElement("guid")
                       subElement.SetAttribute("isPermaLink", "false")
                       element.AppendChild(subElement)
                       subElement.InnerText = item.guid
                   End If

                   subElement = x.CreateElement("pubDate")
                   element.AppendChild(subElement)
                   subElement.InnerText = (item.pubDate.AddHours(-8)).ToString("r")
                   'set item end
               Next
           End If
           'set channel end

           'write to file
           Dim settings As New Xml.XmlWriterSettings()
           settings.Indent = True
           settings.IndentChars = "    "
           settings.Encoding = System.Text.Encoding.UTF8
           Using writer As Xml.XmlWriter = Xml.XmlWriter.Create(path, settings)
               x.WriteTo(writer)
               writer.Flush()
           End Using
       End Sub
   End Class

   Public Class RSSElement
       Private _title As String
       Private _link As String
       Private _description As String
       Private _author As String
       Private _category As String
       Private _comments As String
       Private _guid As String
       Private _pubDate As Date
       Public Property pubDate() As Date
           Get
               Return _pubDate
           End Get
           Set(ByVal value As Date)
               _pubDate = value
           End Set
       End Property

       Public Property guid() As String
           Get
               Return _guid
           End Get
           Set(ByVal value As String)
               _guid = value
           End Set
       End Property

       ''' 
       ''' 回應的URL
       ''' 
       Public Property comments() As String
           Get
               Return _comments
           End Get
           Set(ByVal value As String)
               _comments = value
           End Set
       End Property
       Public Property category() As String
           Get
               Return _category
           End Get
           Set(ByVal value As String)
               _category = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property author() As String
           Get
               Return _author
           End Get
           Set(ByVal value As String)
               _author = value
           End Set
       End Property

       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property
   End Class

   Public Class RSSImage
       Private _title As String
       Private _link As String
       Private _url As String
       Private _description As String
       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property url() As String
           Get
               Return _url
           End Get
           Set(ByVal value As String)
               _url = value
           End Set
       End Property

       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
   End Class

   Public Class RSSFeed
       Private _title As String
       Private _link As String
       Private _description As String
       Private _language As String = "zh-tw"
       Private _copyright As String
       Private _managingEditor As String
       Private _webMaster As String
       Private _guid As String
       Private _pubDate As Date = Now
       Private _lastBuildDate As Date = Now
       Private _category As String
       Private _generator As String
       Private _docs As String = "http://www.rssboard.org/rss-specification"
       Private _image As RSSImage
       Private _items As ArrayList

       ''' 
       ''' 元素型態是RSSElement
       ''' 
       Public Property itmes() As ArrayList
           Get
               Return _items
           End Get
           Set(ByVal value As ArrayList)
               _items = value
           End Set
       End Property
       Public Property image() As RSSImage
           Get
               Return _image
           End Get
           Set(ByVal value As RSSImage)
               _image = value
           End Set
       End Property

       ''' 
       ''' URL
       ''' 
       Public Property docs() As String
           Get
               Return _docs
           End Get
           Set(ByVal value As String)
               _docs = value
           End Set
       End Property

       Public Property generator() As String
           Get
               Return _generator
           End Get
           Set(ByVal value As String)
               _generator = value
           End Set
       End Property

       Public Property category() As String
           Get
               Return _category
           End Get
           Set(ByVal value As String)
               _category = value
           End Set
       End Property

       Public Property lastBuildDate() As Date
           Get
               Return _lastBuildDate
           End Get
           Set(ByVal value As Date)
               _lastBuildDate = value
           End Set
       End Property
       Public Property pubDate() As Date
           Get
               Return _pubDate
           End Get
           Set(ByVal value As Date)
               _pubDate = value
           End Set
       End Property

       Public Property guid() As String
           Get
               Return _guid
           End Get
           Set(ByVal value As String)
               _guid = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property managingEditor() As String
           Get
               Return _managingEditor
           End Get
           Set(ByVal value As String)
               _managingEditor = value
           End Set
       End Property

       ''' 
       ''' E-Mail
       ''' 
       Public Property webMaster() As String
           Get
               Return _webMaster
           End Get
           Set(ByVal value As String)
               _webMaster = value
           End Set
       End Property

       Public Property copyright() As String
           Get
               Return _copyright
           End Get
           Set(ByVal value As String)
               _copyright = value
           End Set
       End Property

       Public Property language() As String
           Get
               Return _language
           End Get
           Set(ByVal value As String)
               _language = value
           End Set
       End Property

       Public Property description() As String
           Get
               Return _description
           End Get
           Set(ByVal value As String)
               _description = value
           End Set
       End Property

       Public Property title() As String
           Get
               Return _title
           End Get
           Set(ByVal value As String)
               _title = value
           End Set
       End Property
       Public Property link() As String
           Get
               Return _link
           End Get
           Set(ByVal value As String)
               _link = value
           End Set
       End Property
   End Class

End Module

使用方法

這個模組中主要有4個類別,分別是

  • RSSFeed:整個RSS的資料都存在這裡面,如果沒有被設定到的屬性,就不會被寫入檔案中(日期除外)
  • RSSImage:用來顯示Logo的資訊,如果沒有Logo就不要把它設定給RSSFeed就好了
  • RSSElement:用來存每一筆新資訊的地方,在RSSFeed中是被ArrayList存起來的
  • RSSGenerator:將路徑與RSSFeed交給其中的createRSS函式,就能產生一個RSS feed檔

使用範例

            Dim rssfeed As New RSSFeed
           rssfeed.title = title
           rssfeed.link = url
           rssfeed.description = title
           rssfeed.generator = "倫倫3號"
           rssfeed.webMaster = "allen080+Tech@gmail.com"
           Dim rssimage As New RSSImage
           rssfeed.image = rssimage
           rssimage.title = title
           rssimage.link = url
           rssimage.url = url + "images/fslogo.jpg"
           rssfeed.itmes = New ArrayList
           Dim notes As ArrayList = gbdatas
           For Each item As GuestBookData In notes
               Dim rsselement As New RSSElement
               rsselement.title = item.title
               rsselement.author = item.eMail + " (" + item.name + ")"
               rsselement.link = item.url
               rsselement.description = item.content
               rsselement.pubDate = item.time
               rsselement.guid = item.url
               rssfeed.itmes.Add(rsselement)
           Next

           Dim rssgen As New RSSGenerator
           rssgen.createRSS(rssfeed, path)

總結

有這樣的一個類別就可以很快的產生出屬於自己的RSS Feed,當然這個xml檔要放在網頁伺服器上,我通常是用IIS就解決了~

完成的檔案可以透過Feed Validator for Atom and RSS這樣的網站來做驗證,不過如果只是一些小警告、小錯誤不理他也沒關係,只要你的RSS Reader不會讀不出來就好了

寫完這個RSS產生函式,如果有空我會找時間看看Atom的不同,如果有必要,也會寫Atom的版本~

參考連結

這裡是關於技術的手札~

也歡迎大家到

倫與貓的足跡

或

到噗浪來

關心一下我唷!
by 倫
 
Copyright 2009 倫倫3號Beta-Log All rights reserved.
Blogger Templates created by Deluxe Templates
Wordpress Theme by EZwpthemes