mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
...
This commit is contained in:
parent
2f962ad21c
commit
911e15e63b
@ -103,7 +103,7 @@ class LiveMint(BasicNewsRecipe):
|
||||
dict(name=['meta', 'link', 'svg', 'button', 'iframe']),
|
||||
classes(
|
||||
'trendingSimilarHeight moreNews mobAppDownload label msgError msgOk taboolaHeight gadgetSlider'
|
||||
' socialHolder imgbig disclamerText disqus-comment-count openinApp2 lastAdSlot bs_logo'
|
||||
' socialHolder imgbig disclamerText disqus-comment-count openinApp2 lastAdSlot bs_logo manualbacklink'
|
||||
' datePublish sepStory premiumSlider moreStory Joinus moreAbout milestone benefitText'
|
||||
)
|
||||
]
|
||||
@ -132,7 +132,9 @@ class LiveMint(BasicNewsRecipe):
|
||||
# remove empty p tags
|
||||
raw = re.sub(
|
||||
r'(<p>\s*)(<[^(\/|a|i|b|em|strong)])', '\g<2>', re.sub(
|
||||
r'(<p>\s* \s*<\/p>)|(<p>\s*<\/p>)|(<p\s*\S+> \s*<\/p>)', '', raw
|
||||
r'(<p>\s* \s*<\/p>)|(<p>\s*<\/p>)|(<p\s*\S+> \s*<\/p>)', '', re.sub(
|
||||
r'(?=<h2>\s*Also\s*Read).*?(?<=</h2>)', '', raw
|
||||
)
|
||||
)
|
||||
)
|
||||
if '<script>var wsjFlag=true;</script>' in raw:
|
||||
|
@ -35,7 +35,8 @@ def parse_lead_image(media):
|
||||
yield '<p>'
|
||||
if 'dsc' in media['image']:
|
||||
yield '<div><img src="{}" alt="{}"></div>'.format(
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True)
|
||||
)
|
||||
else:
|
||||
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||
if 'caption' in media and 'credit' in media:
|
||||
@ -84,7 +85,7 @@ def parse_body(x):
|
||||
if tag == 'inline':
|
||||
yield ''.join(parse_inline(x))
|
||||
elif 'attrs' in x and 'href' in x.get('attrs', ''):
|
||||
yield '<' + tag + ' href = "{}">'.format(x['attrs']['href'])
|
||||
yield '<' + tag + ' href="{}">'.format(x['attrs']['href'])
|
||||
for yld in parse_cont(x):
|
||||
yield yld
|
||||
yield '</' + tag + '>'
|
||||
@ -120,8 +121,7 @@ def parse_article(edg):
|
||||
for item in main['props']['body']:
|
||||
if isinstance(item, dict):
|
||||
if item.get('type', '') == 'inline':
|
||||
for inl in parse_inline(item):
|
||||
yield inl
|
||||
yield ''.join(parse_inline(item))
|
||||
elif isinstance(item, list):
|
||||
for line in item:
|
||||
yield ''.join(parse_body(line))
|
||||
|
@ -34,7 +34,8 @@ def parse_lead_image(media):
|
||||
yield '<p>'
|
||||
if 'dsc' in media['image']:
|
||||
yield '<div><img src="{}" alt="{}"></div>'.format(
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True)
|
||||
)
|
||||
else:
|
||||
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||
if 'caption' in media and 'credit' in media:
|
||||
@ -83,7 +84,7 @@ def parse_body(x):
|
||||
if tag == 'inline':
|
||||
yield ''.join(parse_inline(x))
|
||||
elif 'attrs' in x and 'href' in x.get('attrs', ''):
|
||||
yield '<' + tag + ' href = "{}">'.format(x['attrs']['href'])
|
||||
yield '<' + tag + ' href="{}">'.format(x['attrs']['href'])
|
||||
for yld in parse_cont(x):
|
||||
yield yld
|
||||
yield '</' + tag + '>'
|
||||
@ -119,8 +120,7 @@ def parse_article(edg):
|
||||
for item in main['props']['body']:
|
||||
if isinstance(item, dict):
|
||||
if item.get('type', '') == 'inline':
|
||||
for inl in parse_inline(item):
|
||||
yield inl
|
||||
yield ''.join(parse_inline(item))
|
||||
elif isinstance(item, list):
|
||||
for line in item:
|
||||
yield ''.join(parse_body(line))
|
||||
|
@ -39,7 +39,8 @@ def parse_lead_image(media):
|
||||
yield '<p>'
|
||||
if 'dsc' in media['image']:
|
||||
yield '<div><img src="{}" alt="{}"></div>'.format(
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True)
|
||||
)
|
||||
else:
|
||||
yield '<div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||
if 'caption' in media and 'credit' in media:
|
||||
@ -88,7 +89,7 @@ def parse_body(x):
|
||||
if tag == 'inline':
|
||||
yield ''.join(parse_inline(x))
|
||||
elif 'attrs' in x and 'href' in x.get('attrs', ''):
|
||||
yield '<' + tag + ' href = "{}">'.format(x['attrs']['href'])
|
||||
yield '<' + tag + ' href="{}">'.format(x['attrs']['href'])
|
||||
for yld in parse_cont(x):
|
||||
yield yld
|
||||
yield '</' + tag + '>'
|
||||
@ -124,8 +125,7 @@ def parse_article(edg):
|
||||
for item in main['props']['body']:
|
||||
if isinstance(item, dict):
|
||||
if item.get('type', '') == 'inline':
|
||||
for inl in parse_inline(item):
|
||||
yield inl
|
||||
yield ''.join(parse_inline(item))
|
||||
elif isinstance(item, list):
|
||||
for line in item:
|
||||
yield ''.join(parse_body(line))
|
||||
|
Loading…
x
Reference in New Issue
Block a user