Debian Codegraph @

recipes/theeconomictimes_india.recipe

raw
1 __license__ = 'GPL v3'
2 __copyright__ = '2008-2014, Karthik <[email protected]>, Darko Miletic <darko.miletic at gmail.com>'
3 '''
4 economictimes.indiatimes.com
5 '''
6
7
8 from calibre.web.feeds.news import BasicNewsRecipe, classes
9
10
11 class TheEconomicTimes(BasicNewsRecipe):
12 title = 'The Economic Times India'
13 __author__ = 'Karthik, Darko Miletic'
14 description = 'Financial news from India'
15 publisher = 'economictimes.indiatimes.com'
16 category = 'news, finances, politics, India'
17 oldest_article = 1
18 max_articles_per_feed = 50
19 no_stylesheets = True
20 use_embedded_content = False
21 simultaneous_downloads = 1
22 encoding = 'utf-8'
23 language = 'en_IN'
24 remove_attributes = ['style', 'height', 'width']
25 publication_type = 'newspaper'
26 masthead_url = 'http://economictimes.indiatimes.com/photo/2676871.cms'
27 ignore_duplicate_articles = {'title', 'url'}
28 extra_css = '.summary {font-weight:normal; font-size:normal; }'
29
30 keep_only_tags = [
31 dict(name='h1'),
32 classes('artByline artSyn artImg artText publisher publish_on slideshowPackage'),
33 ]
34 remove_tags = [
35 classes(
36 'story_title storyCollection shareBar sr_widget_free jsSrWidgetFree srwidgetfree_3'
37 ' sr_paid jsSrWidgetPaid ar_wrp arwd_ld_chk adBox custom_ad mgid orn_free_r bold'
38 ),
39 ]
40
41 feeds = [
42 ('Top Stories', 'http://economictimes.indiatimes.com/rssfeedstopstories.cms'),
43 ('News', 'http://economictimes.indiatimes.com/News/rssfeeds/1715249553.cms'),
44 ('Market', 'http://economictimes.indiatimes.com/Markets/markets/rssfeeds/1977021501.cms'),
45 ('Personal Finance', 'http://economictimes.indiatimes.com/rssfeeds/837555174.cms'),
46 ('Infotech', 'http://economictimes.indiatimes.com/Infotech/rssfeeds/13357270.cms'),
47 ('Job', 'http://economictimes.indiatimes.com/Infotech/rssfeeds/107115.cms'),
48 ('Opinion', 'http://economictimes.indiatimes.com/opinion/opinionshome/rssfeeds/897228639.cms'),
49 ('Features', 'http://economictimes.indiatimes.com/Features/etfeatures/rssfeeds/1466318837.cms'),
50 ('Environment', 'http://economictimes.indiatimes.com/rssfeeds/2647163.cms'),
51 ('NRI', 'http://economictimes.indiatimes.com/rssfeeds/7771250.cms'),
52 ]
53
54 def preprocess_html(self, soup):
55 for image in soup.findAll('img', attrs={'src': True}):
56 image['src'] = image['src'].replace('width-300', 'width-640')
57 for img in soup.findAll('img', attrs={'data-original': True}):
58 img['src'] = img['data-original'].replace('photo', 'thumb').replace('quality-100', 'quality-100,width-600,resizemode-4')
59 return soup