Update Haaretz

Fixes #1978381 [Haaretz recipe update](https://bugs.launchpad.net/calibre/+bug/1978381)
This commit is contained in:
Kovid Goyal 2022-06-11 19:02:16 +05:30
parent 4d66abc33b
commit d64bdaf059
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -1,5 +1,8 @@
# -*- mode: python; coding: utf-8; -*-
# vim: set syntax=python fileencoding=utf-8
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2010-2015, Darko Miletic <darko.miletic at gmail.com>' __copyright__ = '2010-2022, Darko Miletic <darko.miletic at gmail.com>'
''' '''
www.haaretz.com www.haaretz.com
''' '''
@ -24,52 +27,63 @@ class Haaretz_en(BasicNewsRecipe):
language = 'en_IL' language = 'en_IL'
needs_subscription = True needs_subscription = True
remove_empty_feeds = True remove_empty_feeds = True
ignore_duplicate_articles = {'url'}
publication_type = 'newspaper' publication_type = 'newspaper'
PREFIX = 'http://www.haaretz.com' PREFIX = 'https://www.haaretz.com'
masthead_url = PREFIX + '/images/logos/HaaretzLogo.gif' LOGIN = 'https://services.haaretz.com/ms-sso/loginUrlEncoded'
LOGOUT = 'https://services.haaretz.com/ms-sso/logout'
extra_css = """ extra_css = """
body{font-family: Verdana,Arial,Helvetica,sans-serif } body{font-family: Merriweather, "Helvetica Neue", Helvetica, Arial, sans-serif }
h1, .articleBody {font-family: Georgia, serif} div.mx time{display: none}
.authorBar {font-size: small} div.my time{display: none}
div.mq time{display: none}
div.mr time{display: none}
""" """
conversion_options = { conversion_options = {
'comment': description, 'publisher': publisher, 'language': language 'comment': description, 'publisher': publisher, 'language': language
} }
keep_only_tags = [dict(name='div', attrs={'id': 'content'})] keep_only_tags = [
dict(name='div', attrs={'data-test': 'articleHeader'}),
dict(attrs={'data-test': 'articleBodyImage'}),
dict(name='div', attrs={'class': ['bu a b d e ', 'bu a b d e']}),
dict(name='div', attrs={'data-test': 'articleBody'})
]
remove_attributes = ['width', 'height'] remove_attributes = ['width', 'height']
remove_tags = [ remove_tags = [
dict(name=['iframe', 'link', 'object', 'embed']), dict(name='div', attrs={ dict(name=['div', 'ul', 'button', 'svg'], attrs={'data-test': ['audioPlayer', 'newsletter', 'relatedArticles', 'tags', 'writerAlertButton', 'IconAlefLogo']})
'class': ['rightcol', 'fblike']}), dict(name='div', attrs={'id': 'article_sso_form'})
] ]
feeds = [ feeds = [
(u'Headlines', 'http://www.haaretz.com/cmlink/1.263335'), (u'Headlines', 'https://www.haaretz.com/srv/haaretz-latest-headlines'),
(u'Opinion', 'http://www.haaretz.com/cmlink/1.628752'), (u'Opinion', 'https://www.haaretz.com/srv/opinion-rss'),
(u'Defence and diplomacy', 'http://www.haaretz.com/cmlink/1.628763'), (u'Security & Aviation', 'https://www.haaretz.com/srv/security-&-aviation-rss'),
(u'National', 'http://www.haaretz.com/cmlink/1.628764'), (u'Israel News', 'https://www.haaretz.com/srv/israel-news-rss'),
(u'International', 'http://www.haaretz.com/cmlink/1.628765'), (u'World News', 'https://www.haaretz.com/srv/world-news-rss'),
(u'Jewish World', 'http://www.haaretz.com/cmlink/1.628766'), (u'Jewish World', 'https://www.haaretz.com/srv/jewish-world-rss'),
(u'Business', 'http://www.haaretz.com/cmlink/1.628767'), (u'Business', 'https://www.haaretz.com/srv/business-rss'),
(u'Real Estate', 'http://www.haaretz.com/cmlink/1.628768'), (u'Science & Health', 'https://www.haaretz.com/srv/science-&-health-rss'),
(u'Features', 'http://www.haaretz.com/cmlink/1.628769'), (u'Life & Culture', 'https://www.haaretz.com/srv/life-&-culture-rss'),
(u'Arts & Leisure', 'http://www.haaretz.com/cmlink/1.628771'), (u'Books', 'https://www.haaretz.com/srv/books-rss'),
(u'Books', 'http://www.haaretz.com/cmlink/1.628772'), (u'Food', 'https://www.haaretz.com/srv/food-rss')
(u'Food & Wine', 'http://www.haaretz.com/cmlink/1.628773'),
(u'Sports', 'http://www.haaretz.com/cmlink/1.628774')
] ]
def get_browser(self): def get_browser(self):
br = BasicNewsRecipe.get_browser(self) br = BasicNewsRecipe.get_browser(self)
br.open(self.PREFIX) br.open(self.PREFIX)
if self.username is not None and self.password is not None: if self.username is not None and self.password is not None:
data = urlencode({'cb': 'parseEngReply', 'newsso': 'true', 'fromlogin': 'true', 'layer': 'eng_login', 'userName': self.username, 'password': self.password # noqa data = urlencode(
}) {
br.open('https://sso.haaretz.com/sso/sso/signIn', data) 'newsso': 'true',
'fromlogin': 'true',
'site': '85',
'layer': 'login',
'anonymousId': '16549476476914546',
'userName': self.username,
'password': self.password
}
)
br.open(self.LOGIN, data)
return br return br
def print_version(self, url):
article = url.rpartition('/')[2]
return 'http://www.haaretz.com/misc/article-print-page/' + article