Update New York Magazine

This commit is contained in:
Kovid Goyal 2023-02-24 21:21:16 +05:30
parent 815cd507b9
commit f851d78e6a
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -24,12 +24,10 @@ class NewYorkMagazine(BasicNewsRecipe):
remove_javascript = True
encoding = 'utf-8'
keep_only_tags = [
classes('lede-text headline-primary article-timestamp by-authors'),
dict(id='main'),
dict(itemprop='articleBody'),
dict(name='article', attrs={'class':lambda x: x and 'article' in x.split()})
]
remove_tags = [
classes('related-stories start-discussion'),
classes('related-stories start-discussion newsletter-flex-text comments-link tags related secondary-area'),
dict(id=['minibrowserbox', 'article-related', 'article-tools'])
]
remove_attributes = ['srcset']
@ -70,6 +68,9 @@ class NewYorkMagazine(BasicNewsRecipe):
return feeds
def preprocess_html(self, soup):
if lede := soup.findAll('div', attrs={'class':lambda x: x and 'lede-image-wrapper' in x.split()}):
if len(lede) > 1:
lede[1].extract()
for img in soup.findAll('img', attrs={'data-src': True}):
img['src'] = img['data-src']
return soup