From 9d9dd5e19e09ce4377399bd9401f46e68af9244d Mon Sep 17 00:00:00 2001 From: Alex Domingo Date: Fri, 19 Apr 2024 13:08:59 +0200 Subject: [PATCH] improve resiliency of HTML feed date parser --- src/term_rst_post/__init__.py | 2 +- src/term_rst_post/newsfeed.py | 2 +- tests/examples/ablog_newsfeed.html | 6 ++++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/term_rst_post/__init__.py b/src/term_rst_post/__init__.py index e9035ac..6af6b73 100644 --- a/src/term_rst_post/__init__.py +++ b/src/term_rst_post/__init__.py @@ -29,4 +29,4 @@ @author: Alex Domingo (Vrije Universiteit Brussel) """ -__version__ = "1.2.1" +__version__ = "1.2.2" diff --git a/src/term_rst_post/newsfeed.py b/src/term_rst_post/newsfeed.py index d35ea5c..d1ba445 100644 --- a/src/term_rst_post/newsfeed.py +++ b/src/term_rst_post/newsfeed.py @@ -85,7 +85,7 @@ def get_top_ablog_news(newslist): motd = { 'title': motd_tag.a.string, 'html_link': motd_tag.a['href'], - 'date': motd_tag.parent.find('li').i.next_sibling.strip(), + 'date': motd_tag.parent.find('i', class_="fa-calendar").find_next_sibling().string, } except AttributeError: raise AttributeError(f"Malformed HTML newsfeed from ABlog, missing news header (H2): '{newslist.name}'") diff --git a/tests/examples/ablog_newsfeed.html b/tests/examples/ablog_newsfeed.html index 5c910c7..8ed17a5 100644 --- a/tests/examples/ablog_newsfeed.html +++ b/tests/examples/ablog_newsfeed.html @@ -23,7 +23,8 @@