| 1 |
#!/usr/bin/env python |
| 2 |
# vim:fileencoding=utf-8 |
| 3 |
# License: GPLv3 Copyright: 2016, Kovid Goyal <kovid at kovidgoyal.net> |
| 4 |
|
| 5 |
from __future__ import absolute_import, division, print_function, unicode_literals |
| 6 |
|
| 7 |
from calibre.web.feeds.news import BasicNewsRecipe, classes, prefixed_classes |
| 8 |
|
| 9 |
|
| 10 |
class TheDailyMail(BasicNewsRecipe): |
| 11 |
title = 'The Daily Mail' |
| 12 |
language = 'en_GB' |
| 13 |
__author__ = 'Kovid Goyal' |
| 14 |
|
| 15 |
use_embedded_content = False |
| 16 |
oldest_article = 2 |
| 17 |
max_articles_per_feed = 20 |
| 18 |
|
| 19 |
compress_news_images = True |
| 20 |
compress_news_images_auto_size = 8 |
| 21 |
no_stylesheets = True |
| 22 |
|
| 23 |
simultaneous_downloads = 1 |
| 24 |
# delay = 2 |
| 25 |
# browser_type = 'webengine' |
| 26 |
|
| 27 |
keep_only_tags = [ |
| 28 |
prefixed_classes('headline--'), |
| 29 |
classes('article-page-headline author-section byline-section'), |
| 30 |
dict(itemprop='articleBody'), |
| 31 |
] |
| 32 |
remove_tags = [classes('related-carousel'), dict(attrs={'data-mol-fe-xpmodule-join-debate': True})] |
| 33 |
|
| 34 |
feeds = [ |
| 35 |
('Home', 'https://www.dailymail.co.uk/home/index.rss'), |
| 36 |
('News', 'https://www.dailymail.co.uk/news/index.rss'), |
| 37 |
('Sport', 'https://www.dailymail.co.uk/sport/index.rss'), |
| 38 |
('TV and Showbiz', 'https://www.dailymail.co.uk/tvshowbiz/index.rss'), |
| 39 |
('Health', 'https://www.dailymail.co.uk/health/index.rss'), |
| 40 |
('Science and Technology', 'https://www.dailymail.co.uk/sciencetech/index.rss'), |
| 41 |
('Money', 'https://www.dailymail.co.uk/money/index.rss'), |
| 42 |
('Property', 'https://www.dailymail.co.uk/property/index.rss'), |
| 43 |
('Motoring', 'https://www.dailymail.co.uk/motoring/index.rss'), |
| 44 |
('Travel', 'https://www.dailymail.co.uk/travel/index.rss'), |
| 45 |
] |
| 46 |
|
| 47 |
def preprocess_html(self, soup): |
| 48 |
for img in soup.findAll(attrs={'data-src': True}): |
| 49 |
img['src'] = img['data-src'] |
| 50 |
return soup |