| 1 |
#!/usr/bin/env python |
| 2 |
from calibre.web.feeds.news import BasicNewsRecipe, classes |
| 3 |
|
| 4 |
|
| 5 |
class scroll(BasicNewsRecipe): |
| 6 |
title = 'Scroll.in' |
| 7 |
__author__ = 'unkn0wn' |
| 8 |
description = ( |
| 9 |
'The leading destination for original reporting on news, politics, and culture in India. ' |
| 10 |
'Our award-winning team of journalists brings readers insightful analysis and opinion on the day’s ' |
| 11 |
'headlines alongside a fresh mix of features on music, books, and cinema.' |
| 12 |
) |
| 13 |
language = 'en_IN' |
| 14 |
masthead_url = 'https://scroll.in/static/assets/scroll-logo.0f68c78dd023e2598248ea107feba562.003.svg' |
| 15 |
|
| 16 |
no_stylesheets = True |
| 17 |
remove_javascript = True |
| 18 |
|
| 19 |
ignore_duplicate_articles = {'title', 'url'} |
| 20 |
remove_attributes = ['style', 'height', 'width'] |
| 21 |
|
| 22 |
extra_css = ''' |
| 23 |
.orange-tag, .article-meta-container { font-size:small; } |
| 24 |
.featured-image, .cms-block-image { text-align:center; font-size:small; } |
| 25 |
''' |
| 26 |
|
| 27 |
keep_only_tags = [dict(name='header'), classes('featured-image article-body')] |
| 28 |
|
| 29 |
remove_tags = [classes('comments-entry-point-meta')] |
| 30 |
|
| 31 |
def parse_index(self): |
| 32 |
index = 'https://scroll.in/' |
| 33 |
sections = ['article', 'magazine'] |
| 34 |
feeds = [] |
| 35 |
soup = self.index_to_soup(index) |
| 36 |
for sec in sections: |
| 37 |
section = sec.capitalize() |
| 38 |
self.log(section) |
| 39 |
articles = [] |
| 40 |
for a in soup.findAll('a', attrs={'href': lambda x: x and x.startswith(index + sec + '/')}): |
| 41 |
url = a['href'].split('?')[0] |
| 42 |
if url in {index + sec + '/', index + sec}: |
| 43 |
continue |
| 44 |
title = self.tag_to_string(a) |
| 45 |
self.log('\t', title, '\n\t\t', url) |
| 46 |
articles.append({'title': title, 'url': url}) |
| 47 |
if articles: |
| 48 |
feeds.append((section, articles)) |
| 49 |
return feeds |
| 50 |
|
| 51 |
def populate_article_metadata(self, article, soup, first): |
| 52 |
if soup.find('h2'): |
| 53 |
article.summary = article.text_summary = self.tag_to_string(soup.find('h2')) |