Move NEwsweek recipe to use current issue to get list of articles.

This commit is contained in:
Kovid Goyal 2008-03-19 21:23:18 +00:00
parent 84ab45c5a9
commit c74cfc55cd

View File

@ -46,6 +46,7 @@ class Newsweek(BasicNewsRecipe):
self.cover_url = small.replace('coversmall', 'coverlarge') self.cover_url = small.replace('coversmall', 'coverlarge')
articles = {} articles = {}
ans = []
key = None key = None
for tag in soup.findAll(['h5', 'h6']): for tag in soup.findAll(['h5', 'h6']):
if tag.name == 'h6': if tag.name == 'h6':
@ -56,6 +57,7 @@ class Newsweek(BasicNewsRecipe):
key = 'uncategorized' key = 'uncategorized'
key = string.capwords(key) key = string.capwords(key)
articles[key] = [] articles[key] = []
ans.append(key)
elif tag.name == 'h5' and key is not None: elif tag.name == 'h5' and key is not None:
a = tag.find('a', href=True) a = tag.find('a', href=True)
if a is not None: if a is not None:
@ -70,7 +72,9 @@ class Newsweek(BasicNewsRecipe):
} }
if art['title'] and art['url']: if art['title'] and art['url']:
articles[key].append(art) articles[key].append(art)
return articles ans = [(key, articles[key]) for key in ans if articles.has_key(key)]
return ans
def postprocess_html(self, soup): def postprocess_html(self, soup):