Created
March 18, 2011 17:37
-
-
Save anonymous/876507 to your computer and use it in GitHub Desktop.
sinopse.recipe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import string, re | |
from calibre import strftime | |
from calibre.web.feeds.recipes import BasicNewsRecipe | |
from calibre.ebooks.BeautifulSoup import BeautifulSoup | |
class Sinopse(BasicNewsRecipe): | |
title = 'Radiobras' | |
__author__ = 'Filipe Fernandes' | |
description = 'Radiobras Sinopses' | |
timefmt = ' [%a, %d %b, %Y]' | |
encoding = 'iso-8859-1' | |
def parse_index(self): | |
url = "http://clipping.radiobras.gov.br/clipping/novo/Classes/SinopsesDetail.php" | |
soup = self.index_to_soup(url) | |
def feed_title(p): | |
return ''.join(p.findAll(text=True, recursive=False)).strip() | |
articles = {} | |
key = None | |
ans = [] | |
for p in soup.findAll(True, | |
attrs={'class':['jornal','titulos-chamadas','textos_sinopse']}): | |
if p['class'] == 'jornal': | |
key = string.upper(feed_title(p)) | |
articles[key] = [] | |
ans.append(key) | |
elif p['class'] in ['titulos-chamadas', 'textos_sinopse']: | |
if p['class'] in ['titulos-chamadas']: | |
title = feed_title(p) | |
description = '' | |
pubdate = strftime('%a, %d %b') | |
url='' | |
summary='' | |
if p['class'] in ['textos_sinopse']: | |
description = feed_title(p) | |
articles[key].append( dict(title=title, url=url, date=pubdate, | |
description=description, content='') ) | |
ans = [(key, articles[key]) for key in ans if articles.has_key(key)] | |
return ans |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment