Debian Codegraph @

recipes/mainichi_en.recipe

raw
1 #!/usr/bin/env python
2 """
3 www.mainichi.jp/english
4 """
5
6 from calibre.web.feeds.news import BasicNewsRecipe
7
8
9 class MainichiEnglishNews(BasicNewsRecipe):
10 title = 'The Mainichi'
11 __author__ = 'unkn0wn'
12
13 description = 'Japanese traditional newspaper Mainichi news in English'
14 publisher = 'Mainichi News'
15 publication_type = 'newspaper'
16 category = 'news, japan'
17 language = 'en_JP'
18
19 index = 'http://mainichi.jp/english/'
20 masthead_url = index + 'images/themainichi.png'
21
22 no_stylesheets = True
23 remove_javascript = True
24 auto_cleanup = True
25
26 ignore_duplicate_articles = {'title', 'url'}
27
28 def parse_index(self):
29 index = 'https://mainichi.jp/english/'
30 sections = ['articles']
31 feeds = []
32 soup = self.index_to_soup(index)
33 for sec in sections:
34 section = sec.capitalize()
35 self.log(section)
36 articles = []
37 for a in soup.findAll('a', attrs={'href': lambda x: x and 'articles' in x}):
38 if a.find('img'):
39 continue
40 url = a['href']
41 if not url.startswith('http'):
42 url = 'https:' + url
43 title = self.tag_to_string(a)
44 self.log('\t', title, '\n\t\t', url)
45 articles.append({'title': title, 'url': url})
46 if articles:
47 feeds.append((section, articles))
48 return feeds