Skip to content

Commit

Permalink
Fix for empty html-description-class
Browse files Browse the repository at this point in the history
  • Loading branch information
reuteras committed Aug 13, 2023
1 parent afc01f8 commit c2443c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
11 changes: 7 additions & 4 deletions src/rssfixer/rss.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down

0 comments on commit c2443c4

Please sign in to comment.