The Artima Developer Community
Sponsored Link

Python Buzz Forum
From Snownews To BottomFeeder

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ng Pheng Siong

Posts: 410
Nickname: ngps
Registered: Apr, 2004

Ng Pheng Siong is just another guy with a website.
From Snownews To BottomFeeder Posted: Feb 7, 2005 3:21 AM
Reply to this message Reply

This post originated from an RSS feed registered with Python Buzz by Ng Pheng Siong.
Original Post: From Snownews To BottomFeeder
Feed Title: (render-blog Ng Pheng Siong)
Feed URL: http://sandbox.rulemaker.net/ngps/rdf10_xml
Feed Description: Just another this here thing blog.
Latest Python Buzz Posts
Latest Python Buzz Posts by Ng Pheng Siong
Latest Posts From (render-blog Ng Pheng Siong)

Advertisement

I got the itch to try BottomFeeder out seriously. I've been using Snownews; "wc -l" reports that my Snownews subscription list is 229-strong. Certainly I'm not about to resubscribe to each of these by hand in BottomFeeder.

BottomFeeder supports importing and exporting feeds. Supposedly it imports from the following file types: BTF, RSS, XML, ini and text. I have no idea what these formats are, so I took the simplest approach: subscribe to a single feed, export it and examine the exported file visually... Ah, the export file is in something called OPML - Outline Processor Markup Language.

Next, googled "snownews opml" and found the following:

Both are Perl programs. The first uses HTML::Entities and the second XML::LibXML and Data:Dumper. It's been a long time since I last installed anything via CPAN and I didn't feel like trying again right then.

Went back to inspecting the exported OPML file... the XML looked simple enough... there, cooked up a chunk of Python code to generate each outline item:

import sys

TEMPLATE = """\
<outline description="..." htmlUrl="" language="en" text="" xmlUrl="%s"/>
"""

while 1:
    line = sys.stdin.readline()
    if not line: break
    print TEMPLATE % line

There were two more steps before the generated output was usable by BottomFeeder:

» Snownews' 'urls' file stores one feed per line; each line contains the feed's URL and a bunch of meta-information, separated by "|". Cooked up a quickie awk script to print just the URL; these URLs are the input to the above Python code

» After running the Python code, filled in the OPML template information by hand.

(Incorporating these two steps into the Python code is left as an exercise for the reader. ;-)

And that was it. BottomFeeder imported the feed successfully and is presently crunching thru the feeds doing whatever it is supposed to be doing...

Read: From Snownews To BottomFeeder

Topic: Fix Mac OS X 10.3&#8217;s Python 2.3.0 Previous Topic   Next Topic Topic: Namespaces are one honking great idea &#8211; let&#8217;s do more of those!

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use