This commit is contained in:
Kovid Goyal 2024-09-18 08:27:58 +05:30
parent c7f0e65fa7
commit 7597538345
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 9 additions and 8 deletions

View File

@ -6,12 +6,13 @@ https://www.economist.com/the-world-in-brief
import json
from urllib.parse import quote, urlencode
from html5_parser import parse
from lxml import etree
from calibre import replace_entities
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
from calibre.ptempfile import PersistentTemporaryFile
from calibre.web.feeds.news import BasicNewsRecipe
from html5_parser import parse
from lxml import etree
def E(parent, name, text='', **attrs):

View File

@ -8,6 +8,7 @@ engadget.com
from calibre.web.feeds.news import BasicNewsRecipe
def classes(classes):
q = frozenset(classes.split(' '))
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
@ -37,7 +38,7 @@ class Engadget(BasicNewsRecipe):
remove_tags = [
dict(name='div', attrs={'class':'caas-content-byline-wrapper'}),
dict(name='div', attrs={'data-component':'ArticleAuthorInfo'}),
classes('commerce-module caas-header caas-prestige-bottom-share caas-share-buttons caas-da caas-3p-blocked commerce-disclaimer notification-upsell-push article-slideshow athena-button email-form')
classes('commerce-module caas-header caas-prestige-bottom-share caas-share-buttons caas-da caas-3p-blocked commerce-disclaimer notification-upsell-push article-slideshow athena-button email-form') # noqa
]
feeds = [(u'Posts', u'https://www.engadget.com/rss.xml')]
@ -86,7 +87,6 @@ class Engadget(BasicNewsRecipe):
except KeyError:
continue
# Reorder the "title" and "content" elements
body_tag = soup.find('body')
title_div = soup.find("div", {"class": "caas-title-wrapper"})
content_div = soup.find("div", {"class": "caas-content-wrapper"})
if title_div and content_div:
@ -94,4 +94,3 @@ class Engadget(BasicNewsRecipe):
soup.body.append(title_div)
soup.body.append(content_div)
return soup

View File

@ -1,8 +1,9 @@
#!/usr/bin/env python
import re
import json
import re
import time
from datetime import datetime, timedelta
from calibre.web.feeds.news import BasicNewsRecipe