| 1 |
__license__ = 'GPL v3' |
| 2 |
__copyright__ = '2008-2014, Karthik <[email protected]>' |
| 3 |
''' |
| 4 |
timesofindia.indiatimes.com |
| 5 |
''' |
| 6 |
|
| 7 |
|
| 8 |
from calibre.web.feeds.news import BasicNewsRecipe |
| 9 |
|
| 10 |
|
| 11 |
def classes(classes): |
| 12 |
q = frozenset(classes.split(' ')) |
| 13 |
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)}) |
| 14 |
|
| 15 |
|
| 16 |
class TheEconomicTimes(BasicNewsRecipe): |
| 17 |
title = 'The Times of India' |
| 18 |
__author__ = 'Karthik' |
| 19 |
description = 'News from the Indian daily Times of India' |
| 20 |
publisher = 'timesofindia.indiatimes.com' |
| 21 |
category = 'news, finances, politics, sports, business, entertainment, India' |
| 22 |
oldest_article = 1 |
| 23 |
max_articles_per_feed = 100 |
| 24 |
no_stylesheets = True |
| 25 |
use_embedded_content = False |
| 26 |
simultaneous_downloads = 1 |
| 27 |
encoding = 'utf-8' |
| 28 |
language = 'en_IN' |
| 29 |
publication_type = 'newspaper' |
| 30 |
masthead_url = 'http://timesofindia.indiatimes.com/photo.cms?msid=2419189' |
| 31 |
extra_css = ''' |
| 32 |
body{font-family: Arial,Helvetica,sans-serif} |
| 33 |
.foto_mg{font-size: 60%; |
| 34 |
font-weight: 700;} |
| 35 |
h1{font-size: 150%;} |
| 36 |
artdate{font-size: 60%} |
| 37 |
artag{font-size: 60%} |
| 38 |
div.storycontent{padding-top: 10px} |
| 39 |
''' |
| 40 |
conversion_options = {'comment': description, 'tags': category, 'publisher': publisher, 'language': language} |
| 41 |
remove_tags_before = dict(name='h1') |
| 42 |
remove_tags_after = dict(name='div', attrs={'class': 'storycontent'}) |
| 43 |
remove_attributes = ['xmlns', 'style'] |
| 44 |
remove_tags = [classes('readalso success_screen poll_withoutLogin hide')] |
| 45 |
|
| 46 |
feeds = [ |
| 47 |
('Recent Stories', 'http://timesofindia.indiatimes.com/rssfeeds/1221656.cms'), |
| 48 |
('India', 'http://timesofindia.indiatimes.com/rssfeeds/-2128936835.cms'), |
| 49 |
('World', 'http://timesofindia.indiatimes.com/rssfeeds/296589292.cms'), |
| 50 |
('Business', 'http://timesofindia.indiatimes.com/rssfeeds/1898055.cms'), |
| 51 |
('Cricket', 'http://timesofindia.indiatimes.com/rssfeeds/4719161.cms'), |
| 52 |
('Sports', 'http://timesofindia.indiatimes.com/rssfeeds/4719148.cms'), |
| 53 |
('Tech', 'http://timesofindia.indiatimes.com/rssfeeds/5880659.cms'), |
| 54 |
('Education', 'http://timesofindia.indiatimes.com/rssfeeds/913168846.cms'), |
| 55 |
('Science', 'http://timesofindia.indiatimes.com/rssfeeds/-2128672765.cms'), |
| 56 |
('Opinion', 'http://timesofindia.indiatimes.com/rssfeeds/784865811.cms'), |
| 57 |
('Entertainment', 'http://timesofindia.indiatimes.com/rssfeeds/1081479906.cms'), |
| 58 |
] |
| 59 |
|
| 60 |
def print_version(self, url): |
| 61 |
return url.replace('/articleshow/', '/articleshowprint/') |
| 62 |
# For mobile version |
| 63 |
# return 'http://m.timesofindia.com/PDAET/articleshow/' + article_id |
| 64 |
|
| 65 |
def get_cover_url(self): |
| 66 |
soup = self.index_to_soup('https://www.magzter.com/IN/Bennett-Coleman-and-Company-Limited/The-Times-of-India-Delhi/Newspaper/') |
| 67 |
return soup.find('img', id=lambda s: s and 'mgd__lhd__cover' in s.split())['src'] |
| 68 |
|
| 69 |
def get_article_url(self, article): |
| 70 |
rurl = article.get('guid', None) |
| 71 |
if '/articleshow/' in rurl: |
| 72 |
return rurl |
| 73 |
|
| 74 |
def postprocess_html(self, soup, first_fetch): |
| 75 |
return self.adeify_images(soup) |