Skip to content

Commit

Permalink
improve resiliency of HTML feed date parser
Browse files Browse the repository at this point in the history
  • Loading branch information
lexming committed Apr 19, 2024
1 parent 0a535c0 commit 9d9dd5e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/term_rst_post/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
@author: Alex Domingo (Vrije Universiteit Brussel)
"""

__version__ = "1.2.1"
__version__ = "1.2.2"
2 changes: 1 addition & 1 deletion src/term_rst_post/newsfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}'")
Expand Down
6 changes: 4 additions & 2 deletions tests/examples/ablog_newsfeed.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ <h2>

<ul class="ablog-archive">
<li>
<i class="fa fa-calendar"></i> 01/01/2021
<i class="fa fa-calendar"></i>
<span>01/01/2021</span>
</li>

<li id="author">
Expand Down Expand Up @@ -70,7 +71,8 @@ <h2>

<ul class="ablog-archive">
<li>
<i class="fa fa-calendar"></i> 01/01/2020
<i class="fa fa-calendar"></i>
<span>01/01/2020</span>
</li>

<li id="published">
Expand Down

0 comments on commit 9d9dd5e

Please sign in to comment.