From: Roland Häder Date: Wed, 15 Jan 2025 02:12:11 +0000 (+0100) Subject: Continued: X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=daca3e837ca3ddd8e9809189a1e93b759aa774b0;p=fba.git Continued: - need to skip invalid table headers, they should be introduced with and then each column but some website may use instead of - strip (trim) strings --- diff --git a/fba/networks/friendica.py b/fba/networks/friendica.py index fcf9e5c..4d252e1 100644 --- a/fba/networks/friendica.py +++ b/fba/networks/friendica.py @@ -87,6 +87,10 @@ def fetch_blocks(domain: str) -> list: tds = line.find_all("td") logger.debug("tds[%s]()=%d", type(tds), len(tds)) + if len(tds) == 0: + logger.warning("No 'td' tag found in line[]='%s' - SKIPPED!", type(line)) + continue + blocked = tds[0].text.strip() reason = tds[1].text.strip() diff --git a/fba/networks/pleroma.py b/fba/networks/pleroma.py index 1d98332..3cfa9a6 100644 --- a/fba/networks/pleroma.py +++ b/fba/networks/pleroma.py @@ -376,8 +376,12 @@ def fetch_blocks_from_about(domain: str) -> dict: tds = line.find_all("td") logger.debug("tds[%s]()=%d", type(tds), len(tds)) - blocked = tds[0].text - reason = tds[1].text + if len(tds) == 0: + logger.warning("No 'td' tag found in line[]='%s' - SKIPPED!", type(line)) + continue + + blocked = tds[0].text.strip() + reason = tds[1].text.strip() logger.debug("blocked='%s',reason='%s' - BEFORE!", blocked, reason) blocked = tidyup.domain(blocked) if blocked != "" else None