1380
Comment:
|
1395
|
Deletions are marked like this. | Additions are marked like this. |
Line 2: | Line 2: |
[[attachment:GoogleNews.py|Download GoogleNews.py]] |
Example: GoogleNews <<BR>> Download: [[attachment:GoogleNews.py]] |
Google News Macro
Example: 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