← Revision 1 as of 2008-04-25 15:08:30
Size: 15
Comment:
|
← Revision 2 as of 2008-04-25 15:18:34 →
Size: 1357
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 1: | Line 1: |
GoogleNews.py |
== Google News Macro == [[attachment:GoogleNews.py]] {{{#!python # create links based on google blog feed results Dependencies = ["time"] from MoinMoin import util, wikiutil, config from MoinMoin.Page import Page class RSStoWiki: def __init__(self, macro): self.macro = macro self.fmt = macro.formatter url = "http://blogsearch.google.com/blogsearch_feeds?hl=en&client=news&scoring=d&q=%22personal+telco%22&ie=utf-8&num=10&output=rss" import feedparser self.f = feedparser.parse(url) self.result = [] def get_link(self, link): self.result.append(self.fmt.url(on=1, href=link) + \ self.fmt.icon('www')) def get_entry_header(self, title): self.result.append(self.fmt.rawHTML(" "+title) + \ self.fmt.url(on=0) + \ self.fmt.rawHTML('<br>')) def get_entries(self): for entry in self.f.entries: if entry.has_key('link'): self.get_link(entry.link) if entry.has_key('title'): self.get_entry_header(entry.title) def get_output(self): self.get_entries() return ''.join(self.result) def execute(macro, args): rss = RSStoWiki(macro) return rss.get_output() }}} |
Google News Macro
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