mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Sports Illustrated by Kovid Goyal
This commit is contained in:
parent
507901b0e9
commit
22d5e11cac
57
recipes/sports_illustrated.recipe
Normal file
57
recipes/sports_illustrated.recipe
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
#!/usr/bin/env python2
|
||||||
|
# vim:fileencoding=utf-8
|
||||||
|
# License: GPLv3 Copyright: 2018, Kovid Goyal <kovid at kovidgoyal.net>
|
||||||
|
|
||||||
|
from __future__ import absolute_import, division, print_function, unicode_literals
|
||||||
|
|
||||||
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
|
def classes(classes):
|
||||||
|
q = frozenset(classes.split(' '))
|
||||||
|
return dict(attrs={
|
||||||
|
'class': lambda x: x and frozenset(x.split()).intersection(q)})
|
||||||
|
|
||||||
|
|
||||||
|
class SI(BasicNewsRecipe):
|
||||||
|
title = 'Sports Illustrated'
|
||||||
|
__author__ = 'Kovid Goyal'
|
||||||
|
language = 'en'
|
||||||
|
encoding = 'utf-8'
|
||||||
|
ignore_duplicate_articles = {'title', 'url'}
|
||||||
|
no_stylesheets = True
|
||||||
|
compress_news_images = True
|
||||||
|
compress_news_images_auto_size = 5
|
||||||
|
remove_attributes = ['style']
|
||||||
|
|
||||||
|
keep_only_tags = [
|
||||||
|
classes('headline article-content'),
|
||||||
|
]
|
||||||
|
remove_tags = [
|
||||||
|
classes('media-video OUTBRAIN'),
|
||||||
|
dict(name='meta'),
|
||||||
|
]
|
||||||
|
|
||||||
|
def preprocess_html(self, soup, *a):
|
||||||
|
for tag in soup.findAll(attrs={'data-src': True}):
|
||||||
|
tag.name = 'img'
|
||||||
|
del tag.contents[:]
|
||||||
|
tag['src'] = tag['data-src']
|
||||||
|
print(tag)
|
||||||
|
return soup
|
||||||
|
|
||||||
|
feeds = [
|
||||||
|
('Top stories', 'https://www.si.com/rss/si_topstories.rss'),
|
||||||
|
('NFL', 'https://www.si.com/rss/si_nfl.rss'),
|
||||||
|
('College Football', 'https://www.si.com/rss/si_ncaaf.rss'),
|
||||||
|
('MLB', 'https://www.si.com/rss/si_mlb.rss'),
|
||||||
|
('NBA', 'https://www.si.com/rss/si_nba.rss'),
|
||||||
|
('College basketball', 'https://www.si.com/rss/si_ncaab.rss'),
|
||||||
|
('NHL', 'https://www.si.com/rss/si_hockey.rss'),
|
||||||
|
('Soccer', 'https://www.si.com/rss/si_soccer.rss'),
|
||||||
|
('Tennis', 'https://www.si.com/rss/si_tennis.rss'),
|
||||||
|
('Fantasy', 'https://www.si.com/rss/si_fantasy.rss'),
|
||||||
|
('MMA', 'https://www.si.com/rss/si_mma.rss'),
|
||||||
|
('Swim Daily', 'https://www.si.com/rss/si_swim_daily.rss'),
|
||||||
|
('Writers', 'https://www.si.com/rss/si_writers.rss'),
|
||||||
|
]
|
Loading…
x
Reference in New Issue
Block a user