Debian Codegraph @

recipes/mainichi.recipe

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