calibre/recipes/theeconomictimes_india.recipe
Kovid Goyal 567040ee1e Perform PEP8 compliance checks on the entire codebase
Some bits of PEP 8 are turned off via setup.cfg
2016-07-29 21:25:17 +05:30

90 lines
4.2 KiB
Plaintext

__license__ = 'GPL v3'
__copyright__ = '2008-2014, Karthik <hashkendistro@gmail.com>, Darko Miletic <darko.miletic at gmail.com>'
'''
economictimes.indiatimes.com
'''
from calibre.web.feeds.news import BasicNewsRecipe
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 = 100
no_stylesheets = True
use_embedded_content = False
simultaneous_downloads = 1
encoding = 'utf-8'
language = 'en_IN'
publication_type = 'newspaper'
masthead_url = 'http://economictimes.indiatimes.com/photo/2676871.cms'
extra_css = """
body{font-family: Arial,Helvetica,sans-serif}
.foto_mg{font-size: 60%;
font-weight: 700;}
h1{font-size: 150%;}
artdate{font-size: 60%}
artag{font-size: 60%}
div.storycontent{padding-top: 10px}
"""
conversion_options = {'comment': description,
'tags': category,
'publisher': publisher,
'language': language
}
remove_tags_before = dict(name='article')
remove_tags_after = [dict(name='article')]
keep_only_tags = [dict(name='h1', attrs={'class': 'title'}),
dict(name='div', attrs={'class': 'bylineFull'}),
dict(name='div', attrs={'class': 'articleImg'}),
dict(name='div', attrs={'class': 'artText'})
]
remove_tags = [dict(name='div', attrs={'class': 'cmtLinks'}),
dict(name='div', attrs={'class': 'raltedTopics'}),
dict(name='div', attrs={'class': 'editorsPick'}),
dict(name='div', attrs={'class': 'articleImg etSpecial'}),
dict(name='div', attrs={'class': 'articleImg artAd'}),
dict(name='div', attrs={'class': 'appPromotion'})
]
remove_attributes = ['xmlns']
feeds = [(u'Top Stories', u'http://economictimes.indiatimes.com/rssfeedstopstories.cms'),
(u'News', u'http://economictimes.indiatimes.com/News/rssfeeds/1715249553.cms'),
(u'Market', u'http://economictimes.indiatimes.com/Markets/markets/rssfeeds/1977021501.cms'),
(u'Personal Finance',
u'http://economictimes.indiatimes.com/rssfeeds/837555174.cms'),
(u'Infotech', u'http://economictimes.indiatimes.com/Infotech/rssfeeds/13357270.cms'),
(u'Job', u'http://economictimes.indiatimes.com/Infotech/rssfeeds/107115.cms'),
(u'Opinion', u'http://economictimes.indiatimes.com/opinion/opinionshome/rssfeeds/897228639.cms'),
(u'Features', u'http://economictimes.indiatimes.com/Features/etfeatures/rssfeeds/1466318837.cms'),
(u'Environment',
u'http://economictimes.indiatimes.com/rssfeeds/2647163.cms'),
(u'NRI', u'http://economictimes.indiatimes.com/rssfeeds/7771250.cms')
]
# Uses the mobile print version. For web print version use
# 'http://economictimes.indiatimes.com/articleshow/<article_id>?prtpage=1'
def print_version(self, url):
rest, sep, article_id = url.rpartition('/articleshow/')
# return 'http://m.economictimes.com/PDAET/articleshow/' + article_id
return 'http://economictimes.indiatimes.com/articleshow/' + article_id + '?prtpage=1'
def get_article_url(self, article):
rurl = article.get('link', None)
if (rurl.find('/quickieslist/') > 0) or (rurl.find('/quickiearticleshow/') > 0):
return None
return rurl
def preprocess_html(self, soup):
for item in soup.findAll(style=True):
del item['style']
return soup
def postprocess_html(self, soup, first_fetch):
return self.adeify_images(soup)