Differences between revisions 6 and 7
Revision 6 as of 2008-04-25 15:32:37
Size: 1395
Comment:
Revision 7 as of 2008-04-25 15:33:36
Size: 1410
Comment:
Deletions are marked like this. Additions are marked like this.
Line 2: Line 2:
Example: GoogleNews <<BR>> Examples: PersonalTelco GoogleNews <<BR>>

Google News Macro

Examples: PersonalTelco GoogleNews
Download: GoogleNews.py

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

Macros/GoogleNews (last edited 2008-04-29 17:57:30 by JasonMcArthur)