__license__ = 'GPL v3' __copyright__ = '2008-2014, Karthik , Darko Miletic ' ''' economictimes.indiatimes.com ''' from calibre.web.feeds.news import BasicNewsRecipe, classes class TheEconomicTimes(BasicNewsRecipe): title = 'The Economic Times India' __author__ = 'Karthik, Darko Miletic' description = 'Financial news from India' publisher = 'economictimes.indiatimes.com' category = 'news, finances, politics, India' oldest_article = 1 max_articles_per_feed = 50 no_stylesheets = True use_embedded_content = False simultaneous_downloads = 1 encoding = 'utf-8' language = 'en_IN' remove_attributes = ['style', 'height', 'width'] publication_type = 'newspaper' masthead_url = 'http://economictimes.indiatimes.com/photo/2676871.cms' ignore_duplicate_articles = {'title', 'url'} extra_css = '.summary {font-weight:normal; font-size:normal; }' keep_only_tags = [ dict(name='h1'), classes('artByline artSyn artImg artText publisher publish_on slideshowPackage'), ] remove_tags = [ classes( 'story_title storyCollection shareBar sr_widget_free jsSrWidgetFree srwidgetfree_3' ' sr_paid jsSrWidgetPaid ar_wrp arwd_ld_chk adBox custom_ad mgid orn_free_r bold' ), ] feeds = [ ('Top Stories', 'http://economictimes.indiatimes.com/rssfeedstopstories.cms'), ('News', 'http://economictimes.indiatimes.com/News/rssfeeds/1715249553.cms'), ('Market', 'http://economictimes.indiatimes.com/Markets/markets/rssfeeds/1977021501.cms'), ('Personal Finance', 'http://economictimes.indiatimes.com/rssfeeds/837555174.cms'), ('Infotech', 'http://economictimes.indiatimes.com/Infotech/rssfeeds/13357270.cms'), ('Job', 'http://economictimes.indiatimes.com/Infotech/rssfeeds/107115.cms'), ('Opinion', 'http://economictimes.indiatimes.com/opinion/opinionshome/rssfeeds/897228639.cms'), ('Features', 'http://economictimes.indiatimes.com/Features/etfeatures/rssfeeds/1466318837.cms'), ('Environment', 'http://economictimes.indiatimes.com/rssfeeds/2647163.cms'), ('NRI', 'http://economictimes.indiatimes.com/rssfeeds/7771250.cms'), ] def preprocess_html(self, soup): for image in soup.findAll('img', attrs={'src': True}): image['src'] = image['src'].replace('width-300', 'width-640') for img in soup.findAll('img', attrs={'data-original': True}): img['src'] = img['data-original'].replace('photo', 'thumb').replace('quality-100', 'quality-100,width-600,resizemode-4') return soup