This commit is contained in:
unkn0w7n 2024-03-16 20:24:18 +05:30
parent 2f962ad21c
commit 911e15e63b
4 changed files with 16 additions and 14 deletions

View File

@ -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*&nbsp;\s*<\/p>)|(<p>\s*<\/p>)|(<p\s*\S+>&nbsp;\s*<\/p>)', '', raw
r'(<p>\s*&nbsp;\s*<\/p>)|(<p>\s*<\/p>)|(<p\s*\S+>&nbsp;\s*<\/p>)', '', re.sub(
r'(?=<h2>\s*Also\s*Read).*?(?<=</h2>)', '', raw
)
)
)
if '<script>var wsjFlag=true;</script>' in raw:

View File

@ -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:
@ -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))

View File

@ -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:
@ -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))

View File

@ -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:
@ -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))