From c2443c48c5fd85da59939982baace05be46f53c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20Reutera=CC=8As?= Date: Sun, 13 Aug 2023 11:08:49 +0200 Subject: [PATCH] Fix for empty html-description-class --- README.md | 2 +- src/rssfixer/rss.py | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index ff0b22e..37e4207 100644 --- a/README.md +++ b/README.md @@ -219,7 +219,7 @@ rssfixer --title "Nucleus CISA KEV" --output nucleus.xml --html --filter-type d # NCSC-SE # https://www.ncsc.se/publikationer/ -rssfixer --html --filter-type div --filter-name 'page-container' --html-entries div --html-entries-class "news-text" --html-title h2 --html-title-class "" --html-description p --html-url a --base-url https://www.ncsc.se --stdout --atom --title "Feed for NCSC-SE" https://www.ncsc.se/publikationer/ +rssfixer --html --filter-type div --filter-name 'page-container' --html-entries div --html-entries-class "news-text" --html-title h2 --html-title-class "" --html-description p --html-description-class "" --html-url a --base-url https://www.ncsc.se --stdout --atom --title "Feed for NCSC-SE" https://www.ncsc.se/publikationer/ ``` If you have other example use case please add them in [show usage examples][sue] in discussions. diff --git a/src/rssfixer/rss.py b/src/rssfixer/rss.py index 5c3168a..6b21db8 100644 --- a/src/rssfixer/rss.py +++ b/src/rssfixer/rss.py @@ -151,10 +151,13 @@ def extract_links_html(soup, arguments): # Continue if URL or title is not found to find other entries continue try: - description = entry.find( - arguments.html_description, - re.compile(arguments.html_description_class), - ).text.strip() + if not arguments.html_description_class: + description = entry.find(arguments.html_description).text.strip() + else: + description = entry.find( + arguments.html_description, + re.compile(arguments.html_description_class), + ).text.strip() except (KeyError, AttributeError): # Ignore description if it's not found description = ""