From 67787fe920f92af3a2a8df808fe3999e87104c26 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Tue, 11 Jul 2023 14:26:58 +0200 Subject: [PATCH] Continued: - need to find all, not just first element ... --- fba/networks/lemmy.py | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/fba/networks/lemmy.py b/fba/networks/lemmy.py index 238f673..3d99838 100644 --- a/fba/networks/lemmy.py +++ b/fba/networks/lemmy.py @@ -152,23 +152,22 @@ def fetch_blocks(domain: str, nodeinfo_url: str) -> list: logger.debug("Checking %d header(s) ...", len(headers)) for header in headers: logger.debug("header[]='%s'", type(header)) - content = header.find(["h2", "h3", "h4", "h5"]) - - logger.debug("content[%s]='%s' - BEFORE!", type(content), content) - if content is not None: - content = content.contents[0] - logger.debug("content[%s]='%s' - AFTER!", type(content), content) - - if content is None: - logger.debug("domain='%s' has returned empty header='%s' - SKIPPED!", domain, header) - continue - elif not isinstance(content, str): - logger.debug("content[]='%s' is not supported/wanted type 'str' - SKIPPED!", type(content)) - continue - elif content.lower() in translations: - logger.debug("Found header with blocked instances - BREAK!") - found = header - break + for content in header.find_all(["h2", "h3", "h4", "h5"]): + logger.debug("content[%s]='%s' - BEFORE!", type(content), content) + if content is not None: + content = str(content.contents[0]) + logger.debug("content[%s]='%s' - AFTER!", type(content), content) + + if content is None: + logger.debug("domain='%s' has returned empty header='%s' - SKIPPED!", domain, header) + continue + elif not isinstance(content, str): + logger.debug("content[]='%s' is not supported/wanted type 'str' - SKIPPED!", type(content)) + continue + elif content.lower() in translations: + logger.debug("Found header with blocked instances - BREAK!") + found = header + break logger.debug("found[]='%s'", type(found)) if found is None: -- 2.39.5