This commit is contained in:
Kovid Goyal 2023-06-26 07:40:20 +05:30
commit f42d0aaf6c
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 38 additions and 13 deletions

View File

@ -14,10 +14,10 @@ class Bloomberg(BasicNewsRecipe):
ignore_duplicate_articles = {'url'}
resolve_internal_links = True
masthead_url = 'https://assets.bwbx.io/s3/javelin/public/hub/images/BW-Logo-Black-cc9035fbb3.svg'
delay = 2
delay = 3 # seconds
extra_css = '''
#auth {font-size:small; font-weight:bold;}
#time {font-size:small;}
#time, .chart {font-size:small;}
#subhead {font-style:italic; color:#404040;}
.news-figure-caption-text, #cap {font-size:small; text-align:center;}
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
@ -94,7 +94,7 @@ class Bloomberg(BasicNewsRecipe):
subhead = '<div id="subhead"><p>' + data['abstract'][0] + '</p><p>' + data['abstract'][1] + '</p></div>'
else:
if 'summary' in data:
subhead = '<div id="subhead">' + data['summary'] + '</div>'
subhead = '<div id="subhead"><p>' + data['summary'] + '</p></div>'
if 'byline' in data:
if data['byline'] is not None:
@ -103,12 +103,12 @@ class Bloomberg(BasicNewsRecipe):
if 'ledeImageUrl' in data:
if data['ledeImageUrl'] is not None:
lede = '<p><img src="{}">'.format(data['ledeImageUrl'].replace('\\', ''))
lede = '<p><img src="{}">'.format(data['ledeImageUrl'])
if data['ledeDescription'] is not None:
caption = '<span id="cap">' + data['ledeDescription'] + '</span>'
body = data['body'].replace('\\', '')
body = data['body']
html = '<html><body>' + cat + title + subhead + auth + lede + caption + '<div>' + body
return html

View File

@ -13,12 +13,12 @@ class Bloomberg(BasicNewsRecipe):
remove_attributes = ['style', 'height', 'width']
ignore_duplicate_articles = {'url', 'title'}
resolve_internal_links = True
oldest_article = 2 # days
delay = 1.5
delay = 5 # seconds
extra_css = '''
#auth {font-size:small; font-weight:bold;}
#time {font-size:small;}
#time, .chart {font-size:small;}
#subhead {font-style:italic; color:#404040;}
#cat {font-size:small; color:gray;}
.news-figure-caption-text, #cap {font-size:small; text-align:center;}
@ -53,11 +53,11 @@ class Bloomberg(BasicNewsRecipe):
feeds = [
('Features',
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Ffeatures%2F&hl=en-US&gl=US&ceid=US:en'),
('News',
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Farticles%2F&hl=en-US&gl=US&ceid=US:en'),
('Opinion', 'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fopinion%2F&hl=en-US&gl=US&ceid=US:en'),
('Newsletters',
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Fnewsletters%2F&hl=en-US&gl=US&ceid=US:en'),
('News',
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Farticles%2F&hl=en-US&gl=US&ceid=US:en'),
('Others', 'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com&hl=en-US&gl=US&ceid=US:en')
]
@ -84,7 +84,7 @@ class Bloomberg(BasicNewsRecipe):
subhead = '<div id="subhead"><p>' + data['abstract'][0] + '</p><p>' + data['abstract'][1] + '</p></div>'
else:
if 'summary' in data:
subhead = '<div id="subhead">' + data['summary'] + '</div>'
subhead = '<div id="subhead"><p>' + data['summary'] + '</p></div>'
if 'byline' in data:
if data['byline'] is not None:

View File

@ -2,6 +2,7 @@
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
from calibre.web.feeds.news import BasicNewsRecipe
from calibre.ptempfile import PersistentTemporaryFile
import json
# a serarch topic, filled into the string below. You can change that to anything google news should be searched for...
@ -16,9 +17,9 @@ class google_news_de(BasicNewsRecipe):
title = 'Google News'
cover_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Google_News_icon.svg/500px-Google_News_icon.svg.png'
# Author
__author__ = 'Volker Heggemann, VoHe'
__author__ = 'Volker Heggemann, VoHe, unkn0wn'
# oldest article to download (in days) ---- can be edit by user
oldest_article = 2
oldest_article = 1.25
# describes itself, ---- can be edit by user
max_articles_per_feed = 200
# speed up the download on fast computers be careful (I test max.20)
@ -37,6 +38,30 @@ class google_news_de(BasicNewsRecipe):
# remove the rubbish (in ebook)
auto_cleanup = True
articles_are_obfuscated = True
def get_obfuscated_article(self, url):
br = self.get_browser()
try:
br.open(url)
except Exception as e:
url = e.hdrs.get('location')
soup = self.index_to_soup(url)
link = soup.find('a', href=True)
skip_sections =[ # add sections you want to skip
'/video/', '/videos/', '/media/', 'podcast-'
]
if any(x in link['href'] for x in skip_sections):
self.log('Aborting Article ', link['href'])
self.abort_article('skipping video links')
self.log('Found link: ', link['href'])
html = br.open(link['href']).read()
pt = PersistentTemporaryFile('.html')
pt.write(html)
pt.close()
return pt.name
# now the content description and URL follows
# feel free to add, wipe out what you need ---- can be edit by user
#