mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
Live Mint: Add support for Saturday special edition
This commit is contained in:
parent
03cac41da7
commit
a4e55ce1e6
@ -1,10 +1,14 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
||||||
|
from datetime import date
|
||||||
|
|
||||||
|
is_saturday = date.today().weekday() == 5
|
||||||
|
|
||||||
|
|
||||||
class LiveMint(BasicNewsRecipe):
|
class LiveMint(BasicNewsRecipe):
|
||||||
title = u'Live Mint'
|
title = u'Live Mint'
|
||||||
|
description = 'Financial News from India.'
|
||||||
language = 'en_IN'
|
language = 'en_IN'
|
||||||
__author__ = 'Krittika Goyal'
|
__author__ = 'Krittika Goyal'
|
||||||
oldest_article = 1 # days
|
oldest_article = 1 # days
|
||||||
@ -14,6 +18,28 @@ class LiveMint(BasicNewsRecipe):
|
|||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
remove_attributes = ['style', 'height', 'width']
|
remove_attributes = ['style', 'height', 'width']
|
||||||
|
|
||||||
|
if is_saturday:
|
||||||
|
keep_only_tags = [
|
||||||
|
dict(name='h1'),
|
||||||
|
dict(name='h2', attrs={'id':'story-summary-0'}),
|
||||||
|
dict(name='picture'),
|
||||||
|
dict(name='div', attrs={'class':'innerBanCaption'}),
|
||||||
|
dict(name='div', attrs={'id':'date-display-before-content'}),
|
||||||
|
dict(name='div', attrs={'class':'storyContent'}),
|
||||||
|
]
|
||||||
|
remove_tags = [
|
||||||
|
classes(
|
||||||
|
'sidebarAdv similarStoriesClass moreFromSecClass'
|
||||||
|
)
|
||||||
|
]
|
||||||
|
feeds = [
|
||||||
|
('News', 'https://lifestyle.livemint.com/rss/news'),
|
||||||
|
('Food','https://lifestyle.livemint.com/rss/food'),
|
||||||
|
('Fashion','https://lifestyle.livemint.com/rss/fashion'),
|
||||||
|
('How to Lounge','https://lifestyle.livemint.com/rss/how-to-lounge'),
|
||||||
|
('Smart Living','https://lifestyle.livemint.com/rss/smart-living'),
|
||||||
|
]
|
||||||
|
else:
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
dict(name='h1'),
|
dict(name='h1'),
|
||||||
dict(name='picture'),
|
dict(name='picture'),
|
||||||
@ -34,7 +60,6 @@ class LiveMint(BasicNewsRecipe):
|
|||||||
('Politics', 'https://www.livemint.com/rss/politics'),
|
('Politics', 'https://www.livemint.com/rss/politics'),
|
||||||
('Science', 'https://www.livemint.com/rss/science'),
|
('Science', 'https://www.livemint.com/rss/science'),
|
||||||
('Industry', 'https://www.livemint.com/rss/industry'),
|
('Industry', 'https://www.livemint.com/rss/industry'),
|
||||||
('Lounge', 'https://www.livemint.com/rss/lounge'),
|
|
||||||
('Education', 'https://www.livemint.com/rss/education'),
|
('Education', 'https://www.livemint.com/rss/education'),
|
||||||
('Sports', 'https://www.livemint.com/rss/sports'),
|
('Sports', 'https://www.livemint.com/rss/sports'),
|
||||||
('Technology', 'https://www.livemint.com/rss/technology'),
|
('Technology', 'https://www.livemint.com/rss/technology'),
|
||||||
@ -50,4 +75,7 @@ class LiveMint(BasicNewsRecipe):
|
|||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for img in soup.findAll('img', attrs={'data-src': True}):
|
for img in soup.findAll('img', attrs={'data-src': True}):
|
||||||
img['src'] = img['data-src']
|
img['src'] = img['data-src']
|
||||||
|
if is_saturday:
|
||||||
|
for img in soup.findAll('img', attrs={'data-img': True}):
|
||||||
|
img['src'] = img['data-img']
|
||||||
return soup
|
return soup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user