Google News Macro

Examples: PersonalTelco GoogleNews
Download: GoogleNews.py
Dependencies: feedparser

Also note this can be generalized to parse any feed in a short form.

   1 # Create links based on Google blog feed results
   2 # Jason McArthur <jason@personaltelco.net>
   3 # Set the url variable below to match your search criteria
   4 # Usage: <<GoogleNews>>
   5 
   6 Dependencies = ["time"]
   7 
   8 from MoinMoin import util, wikiutil, config
   9 from MoinMoin.Page import Page
  10 
  11 class RSStoWiki:
  12     def __init__(self, macro):
  13         self.macro = macro
  14         self.fmt = macro.formatter
  15         # google blog search url. 10 items, sorted by date 
  16 	url = "http://blogsearch.google.com/blogsearch_feeds?hl=en&client=news&scoring=d&q=%22personal+telco%22&ie=utf-8&num=10&output=rss"
  17         import feedparser
  18         self.f = feedparser.parse(url)
  19         self.result = []
  20 
  21     def get_link(self, link):
  22         self.result.append(self.fmt.url(on=1, href=link) + \
  23                            self.fmt.icon('www'))
  24 
  25     def get_entry_header(self, title):
  26         self.result.append(self.fmt.rawHTML(" "+title) + \
  27 			   self.fmt.url(on=0) + \
  28 			   self.fmt.rawHTML('<br>'))
  29 
  30     def get_entries(self):
  31         for entry in self.f.entries:
  32             if entry.has_key('link'):
  33                 self.get_link(entry.link)
  34             if entry.has_key('title'):
  35                 self.get_entry_header(entry.title)
  36 
  37     def get_output(self):
  38 	self.get_entries()
  39         return ''.join(self.result)
  40 
  41 def execute(macro, args):
  42       rss = RSStoWiki(macro)
  43       return rss.get_output()
  44 

GoogleNews.py