← Revision 7 as of 2008-04-25 15:33:36
Size: 1410
Comment:
|
← Revision 8 as of 2008-04-29 11:57:43 →
Size: 140
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 5: | Line 5: |
{{{#!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() }}} |
{{attachment:GoogleNews.py}} |
Google News Macro
Examples: PersonalTelco GoogleNews
Download: GoogleNews.py
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