Skip to content

Instantly share code, notes, and snippets.

Created March 18, 2011 17:37
Show Gist options
  • Save anonymous/876507 to your computer and use it in GitHub Desktop.
Save anonymous/876507 to your computer and use it in GitHub Desktop.
sinopse.recipe
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