Debian Codegraph @

recipes/dna.recipe

raw
1 import re
2
3 from calibre.web.feeds.news import BasicNewsRecipe
4
5
6 class DNAIndia(BasicNewsRecipe):
7 title = 'DNA India'
8 description = 'Mumbai news, India news, World news, breaking news'
9 __author__ = 'Kovid Goyal'
10 language = 'en_IN'
11
12 encoding = 'cp1252'
13 use_embedded_content = False
14
15 no_stylesheets = True
16 auto_cleanup = True
17
18 feeds = [
19 ('Top News', 'http://www.dnaindia.com/syndication/rss_topnews.xml'),
20 ('Popular News', 'http://www.dnaindia.com/syndication/rss_popular.xml'),
21 ('Recent Columns', 'http://www.dnaindia.com/syndication/rss_column.xml'),
22 ('Mumbai', 'http://www.dnaindia.com/syndication/rss,catid-1.xml'),
23 ('India', 'http://www.dnaindia.com/syndication/rss,catid-2.xml'),
24 ('World', 'http://www.dnaindia.com/syndication/rss,catid-9.xml'),
25 ('Money', 'http://www.dnaindia.com/syndication/rss,catid-4.xml'),
26 ('Sports', 'http://www.dnaindia.com/syndication/rss,catid-6.xml'),
27 ('After Hours', 'http://www.dnaindia.com/syndication/rss,catid-7.xml'),
28 ]
29
30 def print_version(self, url):
31 match = re.search(r'newsid=(\d+)', url)
32 if not match:
33 return url
34 return 'http://www.dnaindia.com/dnaprint.asp?newsid=' + match.group(1)
35
36 def postprocess_html(self, soup, first_fetch):
37 for t in soup.findAll(['table', 'tr', 'td']):
38 t.name = 'div'
39
40 a = soup.find(href='http://www.3dsyndication.com/')
41 if a is not None:
42 a.parent.extract()
43 return soup