Debian Codegraph @

recipes/el_pais_babelia.recipe

raw
1 from calibre.web.feeds.news import BasicNewsRecipe
2
3
4 class ElPaisBabelia(BasicNewsRecipe):
5 title = 'El Pais Babelia'
6 __author__ = 'oneillpt'
7 description = 'El Pais Babelia'
8 INDEX = 'http://www.elpais.com/suple/babelia/'
9 language = 'es'
10
11 remove_tags_before = dict(name='div', attrs={'class': 'estructura_2col'})
12 keep_tags = [dict(name='div', attrs={'class': 'estructura_2col'})]
13 remove_tags = [
14 dict(name='div', attrs={'class': 'votos estirar'}),
15 dict(name='div', attrs={'id': 'utilidades'}),
16 dict(name='div', attrs={'class': 'info_relacionada'}),
17 dict(name='div', attrs={'class': 'mod_apoyo'}),
18 dict(name='div', attrs={'class': 'contorno_f'}),
19 dict(name='div', attrs={'class': 'pestanias'}),
20 dict(name='div', attrs={'class': 'otros_webs'}),
21 dict(name='div', attrs={'id': 'pie'}),
22 ]
23 remove_javascript = True
24
25 def parse_index(self):
26 articles = []
27 soup = self.index_to_soup(self.INDEX)
28 feeds = []
29 for section in soup.findAll('div', attrs={'class': 'contenedor_nuevo'}):
30 section_title = self.tag_to_string(section.find('h1'))
31 articles = []
32 for post in section.findAll('a', href=True):
33 url = post['href']
34 if url.startswith('/'):
35 url = 'http://www.elpais.es' + url
36 title = self.tag_to_string(post)
37 if str(post).find('class=') > 0:
38 klass = post['class']
39 if klass != '':
40 self.log()
41 self.log('--> post: ', post)
42 self.log('--> url: ', url)
43 self.log('--> title: ', title)
44 self.log('--> class: ', klass)
45 articles.append({'title': title, 'url': url})
46 if articles:
47 feeds.append((section_title, articles))
48 return feeds