Debian Codegraph @

recipes/hindutamil.recipe

raw
1 #!/usr/bin/env python
2 from calibre.web.feeds.news import BasicNewsRecipe, classes
3
4
5 class hindutamil(BasicNewsRecipe):
6 title = 'இந்து தமிழ் திசை'
7 __author__ = 'unkn0wn'
8 description = (
9 'Hindu Tamil Thisai stands differentiated from the rest of the language dailies in Tamil Nadu '
10 'through its unbiased news coverage, in-depth analysis of international, national and local issues.'
11 )
12 no_stylesheets = True
13 use_embedded_content = False
14 encoding = 'utf-8'
15 language = 'ta'
16 remove_attributes = ['style', 'height', 'width']
17 masthead_url = 'https://static.hindutamil.in/hindu/static/store/images/logo.png'
18
19 def get_browser(self):
20 return BasicNewsRecipe.get_browser(self, user_agent='common_words/based')
21
22 keep_only_tags = [classes('main-article')]
23
24 remove_tags = [classes('newsbot-ads article-details-ads-inner art-follow-title1 dont-miss-it')]
25
26 ignore_duplicate_articles = {'title', 'url'}
27 remove_empty_feeds = True
28
29 def parse_index(self):
30 index = 'https://www.hindutamil.in/'
31 sections = [
32 ('தமிழகம்', 'tamilnadu'),
33 ('இந்தியா', 'india'),
34 ('கருத்துப் பேழை', 'opinion'),
35 ('உலகம்', 'world'),
36 ('வணிகம்', 'business'),
37 ('விளையாட்டு', 'sports'),
38 ('தமிழ் சினிமா', 'cinema'),
39 ('தொழில்நுட்பம்', 'technology'),
40 ('இணைப்பிதழ்கள்', 'supplements'),
41 ('Cartoon', 'cartoon'),
42 ('Life-style', 'life-style'),
43 ]
44 feeds = []
45 soup = self.index_to_soup(index)
46 index = index + 'news/'
47 for sec in sections:
48 section = sec[0]
49 self.log(section)
50 articles = []
51 for a in soup.findAll('a', attrs={'href': lambda x: x and x.startswith(index + sec[1] + '/')}):
52 url = a['href']
53 if url in {index + sec[1] + '/', index + sec[1]}:
54 continue
55 title = self.tag_to_string(a)
56 self.log('\t', title, '\n\t\t', url)
57 articles.append({'title': title, 'url': url})
58 if articles:
59 feeds.append((section, articles))
60 return feeds