Update economist.recipe

Refactor link parsing
This commit is contained in:
unkn0w7n 2025-09-13 14:26:33 +05:30
parent 9287ca7ee6
commit 060e3ae3ce

View File

@ -62,15 +62,11 @@ def parse_txt(ty):
'italic': lambda: [f'<i>{"".join(parse_txt(c))}</i>' for c in children],
'linebreak': lambda: ['<br>'],
'external_link': lambda: [
f'<a href="{href}">{"".join(parse_txt(children[0]))}</a>'
]
if children
else [],
f'<a href="{href}">{"".join(parse_txt(c))}</a>' for c in children
],
'internal_link': lambda: [
f'<a href="{href}">{"".join(parse_txt(children[0]))}</a>'
]
if children
else [],
f'<a href="{href}">{"".join(parse_txt(c))}</a>' for c in children
],
'ufinish': lambda: [text for c in children for text in parse_txt(c)],
'subscript': lambda: [f'<sub>{"".join(parse_txt(c))}</sub>' for c in children],
'superscript': lambda: [f'<sup>{"".join(parse_txt(c))}</sup>' for c in children],
@ -278,6 +274,12 @@ class Economist(BasicNewsRecipe):
)
return ans
def economist_test_article(self):
self.from_web = False
return [('Articles', [{'title': 'test',
'url': 'https://www.economist.com/china/2025/09/10/china-is-ditching-the-dollar-fast'
}])]
def parse_index(self):
# return self.economist_test_article()
edition_date = self.recipe_specific_options.get('date')