mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
pep8
This commit is contained in:
parent
c7f0e65fa7
commit
7597538345
@ -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):
|
||||
|
@ -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)})
|
||||
@ -30,14 +31,14 @@ class Engadget(BasicNewsRecipe):
|
||||
scale_news_images_to_device = True
|
||||
cover_url = 'https://upload.wikimedia.org/wikipedia/commons/b/bb/Engadget-logo.svg'
|
||||
|
||||
keep_only_tags = [
|
||||
keep_only_tags = [
|
||||
classes('caas-content-wrapper caas-title-wrapper'),
|
||||
dict(name='figure')
|
||||
]
|
||||
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
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
||||
@ -94,7 +95,7 @@ def parse_types(x):
|
||||
yield '<p>' + ''.join(parse_cnt(x)) + '</p>'
|
||||
|
||||
elif x.get('__typename', '') == 'BylineBlock':
|
||||
yield '<div class="byl"><br/>' + ''.join(parse_byline(x)) + '</div>'
|
||||
yield '<div class="byl"><br/>' + ''.join(parse_byline(x)) + '</div>'
|
||||
elif x.get('__typename', '') == 'LabelBlock':
|
||||
yield '<div class="sc">' + ''.join(parse_cnt(x)) + '</div>'
|
||||
elif x.get('__typename', '') == 'BlockquoteBlock':
|
||||
|
Loading…
x
Reference in New Issue
Block a user