calibre/recipes/bq_prime.recipe
2022-07-10 20:20:03 +05:30

46 lines
1.5 KiB
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from calibre.web.feeds.news import BasicNewsRecipe, classes
class bq(BasicNewsRecipe):
title = u'BQ Prime'
description = 'Bloomberg Quint: Indias premier multi-platform business and financial news company.'
language = 'en_IN'
__author__ = 'unkn0wn'
oldest_article = 2 # days
max_articles_per_feed = 50
encoding = 'utf-8'
use_embedded_content = False
no_stylesheets = True
remove_attributes = ['style', 'height', 'width']
masthead_url = 'https://www.bqprime.com/icons/bqprime-blue.svg'
ignore_duplicate_articles = {'url'}
keep_only_tags = [
classes(
'story-base-template-m__story-content__1sSai print-story-card story-element-text'
),
dict(name='img', attrs={'property': 'og:image'})
]
remove_tags = [
classes(
'desktop-hidden desktop-only bm-container bookmark-m__bookmark-container__30eHl bookmark-m__container__23o1v'
),
dict(name='div', attrs={'id': 'piano-preview-story'})
]
feeds = [
('Articles', 'https://www.bqprime.com/stories.rss'),
]
def preprocess_raw_html(self, raw_html, url):
return raw_html.replace('<meta property="og:image" content=',
'<img property="og:image" src=')
def preprocess_html(self, soup):
pic = soup.find('img', attrs={'property': 'og:image'})
head = soup.find('h1')
if pic and head:
head.append(pic)
return soup