Geeks With Blogs

News

qrcode

Lance Robinson

Create Your Badge

Lance Robinson is a software engineer in Durham, Chapel Hill, Raleigh, and surrounding areas. More about Lance.

 Subscribe


Lance's TextBox » About Me » My Resume »Twitter

Update:  I changed the feed to default to partial length, only the first 1000 characters of the article body.  To change it to get the full body, add another querystring parameter named full with value true, ie: http://www.textbox1.com/examples/newsgroupfeed.rsb?currentgroup=microsoft.public.dotnet.general&range=10&full=true.

Output any newsgroup as an RSS feed in a half dozen lines of code. Thats pretty impressive, really. How? With RSSBus and a little script that calls RSSBus NntpOps.

Here's an RSS feed of the latest 25 articles in the microsoft.public.dotnet.languages.csharp newsgroup: http://www.textbox1.com/examples/newsgroupfeed.rsb

You can get a different group or a different number of messages by overriding the server, currentgroup, and range in the querystring. For example, here's a feed of the last 10 articles in the microsoft.public.dotnet.general newsgroup:
http://www.textbox1.com/examples/newsgroupfeed.rsb?currentgroup=microsoft.public.dotnet.general&range=10.

Here's how I did it.

First, the starter script code (notice its only 6 lines of code not counting the comments):

<rsb:call op="nntpListArticles">   <rsb:call op="nntpGetArticle?currentarticle=[messageid]">     <!-- format the description -->     <rsb:set attr="rss:description" 
value="From [nntp:from] <br /> [nntp:date] <p /> [nntp:bodytext | Replace('0D','<br>','ishex')]" />
<!-- push this article out as an RSS item --> <rsb:push /> </rsb:call> </rsb:call>

To get a feed of the latest 25 articles in the microsoft.public.dotnet.languages.csharp newsgroup, just call this script like so:

http://rssbus-server/newsgroupfeed.rsb?server=msnews.microsoft.com&currentgroup=microsoft.public.dotnet.languages.csharp&range=25

You can eliminate the need for querystring arguments by defining defaults inside the script itself. We use an rsb:info xml element for this:


<rsb:info treatas="feed" strict="true" description="Articles of a newsgroup">   <input name="currentgroup" default="microsoft.public.dotnet.languages.csharp"/> 
<input name="range" default="5"/>
<input name="server" default="msnews.microsoft.com"/>
</rsb:info> <rsb:call op="nntpListArticles"> <rsb:call op="nntpGetArticle?currentarticle=[messageid]">
    <!-- format the description -->     <rsb:set attr="rss:description" value="From [nntp:from]<br />[nntp:date]<p />[nntp:bodytext | Replace('0D','<br>','ishex')]" /> 
    <!-- provide a link to this message in google groups, also add a guid -->     <rsb:set attr="rss:link">     http://groups.google.com/groups?threadm=[nntp:id | Replace('<', '') | Replace('>', '') | urlencode]
</rsb:set> <rsb:set attr="rss:guid" value="[rss:link]" /> <!-- clear unused data for bandwidth preservation --> <rsb:unset attr="nntp:bodytext" /> <rsb:unset attr="nntp:headers" /> <rsb:unset attr="nntp:subject" /> <!-- push this article out as an RSS item --> <rsb:push /> </rsb:call> </rsb:call>

Also notice the 'treatas="feed"' inside the rsb:info statement. I could instantly turn this into a MS Simple List Extension feed by changing this to 'treatas="list"'.

Technorati : ,

Posted on Friday, November 10, 2006 5:08 PM Programming , Software | Back to top


Comments on this post: Output any newsgroup as an RSS feed in a half dozen lines of code

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Lance Robinson | Powered by: GeeksWithBlogs.net