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
|
import json
|
||||||
from urllib.parse import quote, urlencode
|
from urllib.parse import quote, urlencode
|
||||||
|
|
||||||
|
from html5_parser import parse
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
from calibre import replace_entities
|
from calibre import replace_entities
|
||||||
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
from calibre.ebooks.BeautifulSoup import NavigableString, Tag
|
||||||
from calibre.ptempfile import PersistentTemporaryFile
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
from html5_parser import parse
|
|
||||||
from lxml import etree
|
|
||||||
|
|
||||||
|
|
||||||
def E(parent, name, text='', **attrs):
|
def E(parent, name, text='', **attrs):
|
||||||
|
@ -8,6 +8,7 @@ engadget.com
|
|||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
def classes(classes):
|
def classes(classes):
|
||||||
q = frozenset(classes.split(' '))
|
q = frozenset(classes.split(' '))
|
||||||
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
|
return dict(attrs={'class': lambda x: x and frozenset(x.split()).intersection(q)})
|
||||||
@ -37,7 +38,7 @@ class Engadget(BasicNewsRecipe):
|
|||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name='div', attrs={'class':'caas-content-byline-wrapper'}),
|
dict(name='div', attrs={'class':'caas-content-byline-wrapper'}),
|
||||||
dict(name='div', attrs={'data-component':'ArticleAuthorInfo'}),
|
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')]
|
feeds = [(u'Posts', u'https://www.engadget.com/rss.xml')]
|
||||||
@ -86,7 +87,6 @@ class Engadget(BasicNewsRecipe):
|
|||||||
except KeyError:
|
except KeyError:
|
||||||
continue
|
continue
|
||||||
# Reorder the "title" and "content" elements
|
# Reorder the "title" and "content" elements
|
||||||
body_tag = soup.find('body')
|
|
||||||
title_div = soup.find("div", {"class": "caas-title-wrapper"})
|
title_div = soup.find("div", {"class": "caas-title-wrapper"})
|
||||||
content_div = soup.find("div", {"class": "caas-content-wrapper"})
|
content_div = soup.find("div", {"class": "caas-content-wrapper"})
|
||||||
if title_div and content_div:
|
if title_div and content_div:
|
||||||
@ -94,4 +94,3 @@ class Engadget(BasicNewsRecipe):
|
|||||||
soup.body.append(title_div)
|
soup.body.append(title_div)
|
||||||
soup.body.append(content_div)
|
soup.body.append(content_div)
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
import re
|
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
import time
|
import time
|
||||||
from datetime import datetime, timedelta
|
from datetime import datetime, timedelta
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user