Update Outlook Magazine

This commit is contained in:
Kovid Goyal 2022-05-24 20:21:10 +05:30
parent 4fc4655ee0
commit 613bebe9ee
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1,17 +1,30 @@
import json, re
import json
import re
from calibre.web.feeds.news import BasicNewsRecipe, classes
class outlook(BasicNewsRecipe):
title = 'Outlook Magazine'
__author__ = 'unkn0wn'
description = ''
description = (
'Outlook covers the latest India news, analysis, business news and long-form stories on culture,'
' money market and personal finance. Read India\'s best online magazine.'
)
language = 'en_IN'
use_embedded_content = False
no_stylesheets = True
remove_javascript = True
remove_attributes = ['height', 'width', 'style']
ignore_duplicate_articles = {'url'}
resolve_internal_links = True
keep_only_tags = [classes('__story_detail')]
remove_tags = [
classes(
'social_sharing_article left_trending left-sticky __tag_links next_prev_stories downarrow uparrow more_from_author_links next prev'
)
]
def parse_index(self):
soup = self.index_to_soup('https://www.outlookindia.com/')
@ -31,13 +44,15 @@ class outlook(BasicNewsRecipe):
desc = ''
p = h3.find_next_sibling('p')
if p:
desc = self.tag_to_string(desc)
self.log('\t\tFound article:', title)
self.log('\t\t\t', url)
desc = self.tag_to_string(p)
self.log('\t', title)
self.log('\t', desc)
self.log('\t\t', url)
ans.append({'title': title, 'url': url, 'description': desc})
return [('Articles', ans)]
def preprocess_raw_html(self, raw, *a):
return raw
m = re.search('<!-- NewsArticle Schema -->.*?script.*?>', raw, flags=re.DOTALL)
raw = raw[m.end():].lstrip()
data = json.JSONDecoder().raw_decode(raw)[0]